Topic: Sending email from command prompt?

I am trying to send a email from the command prompt using the sendmail.    (The end goal is to have this email launch a text message on a cell phone.)    I have tried various configurations of the parameters, but nothing seems to work. 

Questions:

1.  Has anyone got this to work from the command prompt? 
2.  Do you have an example parameter list?   Regardless of the parameters that I input, it just prints out the help screen and quickly exits back to a prompt.   The -H parameter example from the help screen is confusing as to what all is supposed to be included.
3.  Is there some other way to send emails from the command line? 

I searched the forums, but only found stuff about sending email from widgets.   I would like to be able to send from a lower code level.  Well, to be honest, I do not want to spend days trying to figure out what widget are, how they are coded and how to register them.   My end goal for this Infocast box is to just have it run as a home control robot.

Thanks.

Re: Sending email from command prompt?

Your best bet is to Google this, since there is lots of information out there.

In general though, it goes something like this:

#sendmail recipient@example.com -f sender@example.com  -S smtp.example.com -au senderusername -ap senderpassword < mail.txt

...where the body of the email is in "mail.txt".

You'll need access to an SMTP server somewhere, and your credentials - there is no SMTP server on the device.

Re: Sending email from command prompt?

Well, I googled and experimented and nothing worked.  I found a command line program for a Windows Box and used that to verify that the mail server, username. password, etc were correct. Therefore, I assumed that my ISP was using a security option that Chumby / Infocast could not handle.   So next I found gmx.com that offers free email without lots of security options.  Again, I used the Windows box to make sure all the parameters were correct.  Still Chumby/ Infocast does nothing but fail. 

So I googled some more and learned that strace would show me the data traffic.  So I added an strace before my sendmail command.    The final part of the strace is as follows:

read(0, "220 mail.gmx.com GMX Mailservices"..., 4096) = 52
read(0, "250 2.0.0 ok {mp-us001}\r\n"..., 4096) = 25
write(1, "EHLO none\r\n"..., 11)        = 11
read(0, "250-mail.gmx.com GMX Mailservices"..., 4096) = 142
write(1, "AUTH LOGIN\r\n"..., 12)       = 12
read(0, "334 VXNlcm5hbWU6\r\n"..., 4096) = 18
write(1, "\r\n"..., 2)                  = 2
read(0, "334 VXNlcm5hbWU6\r\n"..., 4096) = 18
write(1, "\r\n"..., 2)                  = 2
read(0, "334 VXNlcm5hbWU6\r\n"..., 4096) = 18
write(2, "sendmail:  failed\n"..., 18sendmail:  failed
)  = 18
exit_group(1)                           = ?

Lots more googling, and I learned that  VXNlcm5hbWU6 is base64 for Username: .  The mail server is asking for my username and sendmail responds three times with an empty string.   For this mail account my username is banjo42@gmx.com.   In the sendmail I have, -au banjo42@gmx.com    Therefore, since I am setting the parameter and sendmail is not using it,  I can only conclude that sendmail must be broken.   

My busybox reports: BusyBox v1.16.0 (2010-11-05 18:58:58 PDT)    Is there a newer version available?

Thanks.

---- Steve

Re: Sending email from command prompt?

Your username should not contain the email domain, ie use "banjo42", not "banjo42@gmx.com".  I don't think you can have a space either, so try "-aubanjo42"

Re: Sending email from command prompt?

Success!

The trick is in the username and password.   These cannot contain ANY white space.  The help file shows:
-au<username>    for me this translates  to -au"banjo42@gmx.com"        Notice how the -au is immediately followed by the ".

The quotes "" are required.    The issue of no white space and quotes required applies to the password also.  Be aware that if your password contains any special characters or punctuation then you may have to precede these with the back slash escape character.

Re: Sending email from command prompt?

Thanks for your help Duane.   At least for my case, the domain is required as part of the username.   I agree that this used to not be required.   I think it is at least sometimes required now because several domains will use the same SMTP server.  I was originally trying to leave the domain name off.  The SMTP server kept reporting that the username and password did not match.   Once, I put the domain name on the end, it got real happy.

However, my last post about the quotes being required is not accurate.  The quotes are optional.   The username parameter

-au"banjo42@gmx.com"

or

-aubanjo42@gmx.com

both work.  The one with the quotes is more readable by humans.

Re: Sending email from command prompt?

Glad it worked for you.