DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Send email from cmdline !  (Read 33,729 times)

hulkbuster

  • Participant
  • Joined in 2009
  • *
  • Posts: 259
Send email from cmdline !
« on: May 10, 2014, 05:21 AM »
Hello,
    i just wanted to know is it possible to really send an email from cmdline ! I checked many youtube videos , but i was not clear enough.
Also i googled and found some tools that could do so.

But it just goes over my head. Can someone tell me the method to do so. cmdline tool and another
For reasons , like time taken when composing an email from yahoo or gmail is what i don't like.

Thank you.
ClipDiary 5.3/ Smadav 2018/ Some Sense

x16wda

  • what am I doing in this handbasket?
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
    • Participated in NANY Challenge Once
Re: Send email from cmdline !
« Reply #1 on: May 10, 2014, 12:31 PM »
Blat is a well regarded command line emailer. I have this on all my servers for sending notifications, job results, etc. Simple syntax, good debugging options, and options for almost everything. (Of course the license prohibits sending spam.)

Blat is for sending emails - it is not written for composing emails. It presumes you have some content that you want to send. If you need to run a program to compose your message, then you might as well use a normal email client.
vi vi vi - editor of the beast

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,954
Re: Send email from cmdline !
« Reply #2 on: May 10, 2014, 03:35 PM »
This might be more interesting: http://caspian.dotconf.net/menu/Software/SendEmail/

Basic use would be:
sendEmail -f <your email address> -t <receiver mail adress(es)> -u <preferred subject> -m <message you want to send> -s <name or IP from your mail server(: optional port)>

or if this is more clear:
sendEmail -f me@hulkbuster.com -t info@messagereceiver.com -u "My first message" -m "Hello world" -s internal.mail.server


There are lots more options, the included help is quite clear.
The easy path is usually downhill...
« Last Edit: May 10, 2014, 03:49 PM by Shades »

hulkbuster

  • Participant
  • Joined in 2009
  • *
  • Posts: 259
Re: Send email from cmdline !
« Reply #3 on: May 10, 2014, 05:56 PM »
This might be more interesting: http://caspian.dotconf.net/menu/Software/SendEmail/

Basic use would be:
sendEmail -f <your email address> -t <receiver mail adress(es)> -u <preferred subject> -m <message you want to send> -s <name or IP from your mail server(: optional port)>

or if this is more clear:
sendEmail -f me@hulkbuster.com -t info@messagereceiver.com -u "My first message" -m "Hello world" -s internal.mail.server


There are lots more options, the included help is quite clear.

No mate , its not working. I follow ur cmdline. I want to mail using my gmail account to a yahoo account.
The homepage doesn't provide enough material to comprehend.
ClipDiary 5.3/ Smadav 2018/ Some Sense

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Send email from cmdline !
« Reply #4 on: May 10, 2014, 06:07 PM »
It's not command line but Thunderbird can be configured to access many web mail accounts as pop3.  One example is hotmail.  It can probably do gmail too but I'm not certain.

http://kb.mozillazine.org/Using_webmail_with_your_email_client

Edit:  also there may be an AddOn for Thunderbird that does the gmail setup for you.
« Last Edit: May 10, 2014, 06:30 PM by MilesAhead »

hulkbuster

  • Participant
  • Joined in 2009
  • *
  • Posts: 259
Re: Send email from cmdline !
« Reply #5 on: May 10, 2014, 08:59 PM »
For the first link: An Email Program for Sending SMTP Mail from a Command Line An Email Program for Sending SMTP Mail from a Command Line
The commands were:

SendEmail -f urname@gmail.com -t receiver@yahoo.com -s "SERVER[:PORT] (If using gmail, -s smtp.gmail.com:587)" -xu "urname@gmail.com" -xp "password" -u "Hello their" -m "How are you."

This is how it would look:
SendEmail -f urname@gmail.com -t receiver@yahoo.com -s smtp.gmail.com:587 -xu urname@gmail.com.com -xp xxxxx -u "Hello their" -m "How are you."

But i am getting an error
Code
Authentication not supported by the remote SMTP server!

Must issue a STARTTLS command first. o7sm20727708eew.25 - gsmtp
Checking more on Blat.
ClipDiary 5.3/ Smadav 2018/ Some Sense

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,954
Re: Send email from cmdline !
« Reply #6 on: May 10, 2014, 09:52 PM »
There are 2 different versions for Windows. One that supports TLS and one that doesn't. It is important you use the correct one and perhaps add: -o tls=auto at the end of the line you created.
The easy path is usually downhill...

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Send email from cmdline !
« Reply #7 on: May 10, 2014, 09:58 PM »
Another cli client

http://www.codeproject.com/Tips/418420/Send-Email-from-Command-Line-using-GMail-Account

hulkbuster

  • Participant
  • Joined in 2009
  • *
  • Posts: 259
Re: Send email from cmdline !
« Reply #8 on: May 14, 2014, 05:02 PM »
Hello so their were two versions of this program i.e.,
1:SendEmail TLS supported
2:SendEmail No TLS support

For TLS support the command i gave was:
Code
SendEmail -f urname@gmail.com -t receiver@yahoo.com -s smtp.gmail.com:587 -xu urname@gmail.com.com -xp xxxxx -u "Hello their" -m "How are you." -o tls=yes
The error message i got was " SMTP-AUTH: Authentication to smtp.gmail.com:587 failed. "

For No TLS support :
Code
SendEmail -f urname@gmail.com -t receiver@yahoo.com -s smtp.gmail.com:587 -xu urname@gmail.com.com -xp xxxxx -u "Hello their" -m "Hello there." -o tls=no
The error message i got was" Authentication not supported by the remote SMTP server!
                             Must issue a STARTTLS command first. gn3sm4344660pbc.32 - gsmtp"

I don't understand what i am doing wrong.
Has anyone tried it, it would prove really useful to have a command based email support.
Another cli client
http://www.codeproject.com/Tips/418420/Send-Email-from-Command-Line-using-GMail-Account
This was really confusing , there is no sendmail.exe file that could relay the commands:
Code
mailsend.exe -to %1 -from %2 -sub "test from windows" -starttls -port 587 -auth -smtp smtp.gmail.com -user "%2" -pass %SMTP_USER_PASS% -M "hello one liner" -log "c:\Users\mqt\Downloads\m.log"
Sorry i had downloaded the unix version, but after using the windows version as well, it doens't work.

Blat really was tricky, having one to install all the profile and still not able to work with the commands.
Any suggestion would be great.

Thank you.
ClipDiary 5.3/ Smadav 2018/ Some Sense
« Last Edit: May 14, 2014, 05:10 PM by hulkbuster »

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,954
Re: Send email from cmdline !
« Reply #9 on: May 14, 2014, 10:04 PM »
Some 3rd party mail servers require you to login using POP3/IMAP before you are allowed to send mail through their SMTP server (spam prevention method). And given the amount of users the Google mail servers have to use that method. Their traffic is already impressive enough with this method.

You don't have access to another mail server?
The easy path is usually downhill...

x16wda

  • what am I doing in this handbasket?
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
    • Participated in NANY Challenge Once
Re: Send email from cmdline !
« Reply #10 on: May 15, 2014, 01:14 AM »
Blat really was tricky, having one to install all the profile and still not able to work with the commands.
Any suggestion would be great.

Actually you should be able to put all the required information on one command line, although installing the server and from info in the profile makes it easier for subsequent use. But the info you would need to use Blat would be exactly the same info you would need to set up an email client like Outlook or Thunderbird or whatever - account name, ISP servers, password, etc - plus what you would need for your email - subject, recipient, body.

One of the things you need to know is the name of either your email smtp server or your recipient's email server. Yours is preferable, the recipient's server might block your email because it would (probably) be coming from a residential or dynamic address. Your own ISP would be more likely to allow an email from one of its own addresses to run through its servers.

To send a text file named "mymessage.txt" as the body of the message to joe@email1.com, you'd do something like this:

blat.exe mymessage.txt -to joe@email1.com -from hulkbuster@myemail.com -subject "This is an email" -server smtp-server.location.rr.com -u hulkbuster@myemail.com -pw hulkbusterpassword -debug

The -u and -pw options might be needed for authentication; your ISP would want to make sure you have an account. The -debug option should show you the conversation between Blat and your ISP, which can be extremely useful for troubleshooting. I just used the Roadrunner server name pattern for this example.
vi vi vi - editor of the beast

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: Send email from cmdline !
« Reply #11 on: May 15, 2014, 06:32 AM »
For TLS support the command i gave was:
Code
SendEmail -f urname@gmail.com -t receiver@yahoo.com -s smtp.gmail.com:587 -xu urname@gmail.com.com -xp xxxxx -u "Hello their" -m "How are you." -o tls=yes
The error message i got was " SMTP-AUTH: Authentication to smtp.gmail.com:587 failed. "
Are you sure you want to use this: -xu urname@gmail.com.com ? Shouldn't that be like: -xu urname@gmail.com
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

jpfx

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 155
Re: Send email from cmdline !
« Reply #12 on: May 15, 2014, 03:12 PM »
meh, just sayin explaining how to use command line e-mail tools for yahoo or gmail is too close to explaining how to send spam for me to be comfortable.
       |\      _,,,---,,_         
ZZZzzz /,`.-'`'    -.  ;-;;, 
      |,4-  ) )-,_. ,\ (  `'-'    
     '---''(_/--'  `-'\_)

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 3,217
Re: Send email from cmdline !
« Reply #13 on: May 15, 2014, 09:05 PM »
the info you would need to use Blat would be exactly the same info you would need to set up an email client like Outlook or Thunderbird or whatever
Agreed, though as I don't know much about it, I've found subtle differences between clients, anti-spam programs etc. hair-tearing, especially in their terminology regarding connection type and authentication.

hulkbuster

  • Participant
  • Joined in 2009
  • *
  • Posts: 259
Re: Send email from cmdline !
« Reply #14 on: May 16, 2014, 06:29 AM »
To send a text file named "mymessage.txt" as the body of the message to joe@email1.com, you'd do something like this:
blat.exe mymessage.txt -to joe@email1.com -from hulkbuster@myemail.com -subject "This is an email" -server smtp-server.location.rr.com -u hulkbuster@myemail.com -pw hulkbusterpassword -debug
The -u and -pw options might be needed for authentication; your ISP would want to make sure you have an account. The -debug option should show you the conversation between Blat and your ISP, which can be extremely useful for troubleshooting. I just used the Roadrunner server name pattern for this example.

Is this process of correct first to install:
Code
Blat -install <server addr> <sender's addr> [<try>[<port>[<profile>]]]
Blat -install smtp.gmail.com myadd@gmail.com 2 587 hulk

Sending an email:
Code
Blat -install <server addr> <sender's addr> [<try>[<port>[<profile>]]]
blat.exe mymessage.txt -to joe@email1.com -from hulkbuster@myemail.com -subject "This is an email" -server smtp-server.location.rr.com -u hulkbuster@myemail.com -pw hulkbusterpassword -debug
or
  blat.exe c:\a.txt -to joe@email1.com -from hulkbuster@myemail.com -subject "This is an email" -server smtp-server.location.rr.com -u hulkbuster@myemail.com -pw hulkbusterpassword -debug
ClipDiary 5.3/ Smadav 2018/ Some Sense

Original address: https://www.donationcoder.com/forum/index.php?topic=37915.0