benhewitt97
Posts: 16
Joined: Thu Apr 18, 2013 5:26 pm

SMTP Mail Server Help

Wed Jun 05, 2013 3:01 pm

Hi all,
I've recently been trying to set up my Pi (Model B, 512 Ram) to sent me emails when the temperature gets too high. However, after downloading SSMTP and configuring it, when i go to test it using:

Code: Select all

echo "Test" | mail -s "Test" myemail@mydomain.co.uk
I get the error:

Code: Select all

mail: cannot send message: Process exited with a non-zero status
Any ideas, or a way around this?
Thanks, Ben

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: SMTP Mail Server Help

Wed Jun 05, 2013 6:13 pm

benhewitt97 wrote:I get the error:

Code: Select all

mail: cannot send message: Process exited with a non-zero status
Try running the command with an additional -d parameter to get some more debug information to help determine the cause of the issue:

Code: Select all

echo "Test" | mail -d -s "Test" myemail@mydomain.co.uk

benhewitt97
Posts: 16
Joined: Thu Apr 18, 2013 5:26 pm

Re: SMTP Mail Server Help

Wed Jun 05, 2013 8:29 pm

Just tried that, seems to be no debug option in the mail module... Odd. I tried the command after rephrasing, and removing the 'echo' as i'm not sure what purpose it plays, so my code is now:

Code: Select all

 mail -s "Test" sensei441@hotmail.co.uk
which, on a new line, prints 'Cc:' which i can type into but not end and send the message. I checked my error logs, and noticed this:

Code: Select all

Jun 5 17:56:23 raspberrypi sSMTP[3477]: Creating SSL connection to host
Jun 5 17:56:23 raspberrypi sSMTP[3477]: SSL connection using RSA_ARCFOUR_SHA1
Jun 5 17:56:24 raspberrypi sSMTP[3477]: Authorization failed (535 5.7.8 {BADCREDENTIALS} ay7sm11977366wib.9 - gsmtp)
Any ideas? I really don't want to give up on this!

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: SMTP Mail Server Help

Thu Jun 06, 2013 2:02 pm

benhewitt97 wrote:Any ideas? I really don't want to give up on this!
Can you post the details of your ssmtp.conf configuration file?

benhewitt97
Posts: 16
Joined: Thu Apr 18, 2013 5:26 pm

Re: SMTP Mail Server Help

Thu Jun 06, 2013 4:12 pm

Sure, here you go:

Code: Select all

root=mymail@gmail.com
mailhub=smtp.gmail.com:587
hostname=raspberrypi
FromLineOverride=YES
AuthUser=mymail@gmail.com
AuthPass=mypass
UseSTARTTLS=YES
I'm probably missing something stupid!

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: SMTP Mail Server Help

Thu Jun 06, 2013 4:45 pm

benhewitt97 wrote:Sure, here you go:

Code: Select all

root=mymail@gmail.com
mailhub=smtp.gmail.com:587
hostname=raspberrypi
FromLineOverride=YES
AuthUser=mymail@gmail.com
AuthPass=mypass
UseSTARTTLS=YES
I'm probably missing something stupid!
I don't see anything obviously wrong with that config file as long as you are replacing "mymail" and "mypass" with your gmail account username and password. The "Authorization failed (535 5.7.8 {BADCREDENTIALS}" message is saying that your username and password details are not being accepted. Have you logged into your gmail account via webmail recently to check that there are no issues with the account?

benhewitt97
Posts: 16
Joined: Thu Apr 18, 2013 5:26 pm

Re: SMTP Mail Server Help

Thu Jun 06, 2013 4:55 pm

Yeah, i can login to webmail just fine... Could this have anything to with my port choice or ISP? I can't find anyone else with the same error. Are there any alternatives to SSMTP? I've tried Exmi4, but couldn't end my messages for some reason.

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: SMTP Mail Server Help

Thu Jun 06, 2013 5:10 pm

benhewitt97 wrote:Yeah, i can login to webmail just fine... Could this have anything to with my port choice or ISP? I can't find anyone else with the same error. Are there any alternatives to SSMTP? I've tried Exmi4, but couldn't end my messages for some reason.
No, I don't believe so. That error message is coming from gmail which means you are connecting to it OK, and port 587 is the correct port for a SMTP TLS connection. You could try Exim or lots of other programs but you are going to run into the same issue if it is an authentication issue, which it appears to be. Have you got an email account with your ISP that you could try using instead of your Gmail account? If so search their support site for details of the settings for their outgoing SMTP server and try using those in the configuration file instead.

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: SMTP Mail Server Help

Thu Jun 06, 2013 5:41 pm

I've installed ssmtp and mailutils and recreated your setup using my gmail account, and I can send without any issues. However if I change my password to an incorrect password in the ssmtp config file I get exactly the same error message as you. This does suggest there is something incorrect in the login credentials you have configured in the config file.


TVpi
Posts: 1
Joined: Mon Jun 10, 2013 9:28 pm

Re: SMTP Mail Server Help

Mon Jun 10, 2013 9:32 pm

I had the same problem! Do you use spaces in your password? I did, but when I changed my gmail password to something without spaces (and updated the ssmtp.conf accordingly), it worked fine. My guess is mailx doesn't like certain characters when it's parsing that conf file, space being one of them. Hope it works for you!

benhewitt97
Posts: 16
Joined: Thu Apr 18, 2013 5:26 pm

Re: SMTP Mail Server Help

Fri Jun 14, 2013 5:38 pm

Hi all!
I just had a go at changing my password, and fixed the problem! Thanks so much! Now to find a way of reguarly compiling and sending a system stats file....

av2kk
Posts: 21
Joined: Tue Jul 17, 2012 11:01 am

Re: SMTP Mail Server Help

Fri Jul 12, 2013 12:45 am

Hi All,
I too struggled with all the above but finally what made it work for me is adding the following line in the /etc/ssmtp/ssmtp.conf at the end of all the above:
AuthLogin=Yes
Hope this helps some one like me.

david91
Posts: 2
Joined: Mon Jun 30, 2014 11:22 pm

Re: SMTP Mail Server Help

Tue Jul 01, 2014 12:25 pm

benhewitt97 wrote:Hi all!
I just had a go at changing my password, and fixed the problem! Thanks so much! Now to find a way of reguarly compiling and sending a system stats file....
hi, can you please tell me exactly how you resolved the issue? i have tried everything mentioned above but i still fix the problem. thanks for your reply

edvintide
Posts: 1
Joined: Sun Sep 28, 2014 5:04 am

Re: SMTP Mail Server Help

Sun Sep 28, 2014 5:15 am

Hi, I had a similar problem. For anyone that might be interested, I think Google started blocking my logins from my raspberry pi (maybe something related to non-human usage?).

I solved my problem by creating an app password for my raspberry based on user bonelifer's comment:

Tommmii
Posts: 2
Joined: Thu Nov 22, 2012 7:14 pm

Re: SMTP Mail Server Help

Sun Sep 28, 2014 11:08 am

had same issue...after i turned on 2step authentication on the google account...duh.
generated an app password on the google security page, all is well.

marcosartore
Posts: 13
Joined: Thu Jan 15, 2015 3:07 pm

Re: SMTP Mail Server Help

Thu Jan 15, 2015 3:11 pm

Hello,
had the same problem, fixed by activating a "less secure" flag inside gmail, visiting this link: https://www.google.com/settings/security/lesssecureapps
Hope this helps,
Marco

midzu
Posts: 1
Joined: Sun Aug 02, 2015 11:06 am

Re: SMTP Mail Server Help

Wed Oct 14, 2015 8:01 pm

@ marcosartore thank you so much ;) . I spent my whole day to find a solution to this problem...
It really works : ).
Midzu.

chandrasekar
Posts: 2
Joined: Sat Jan 23, 2016 4:50 pm

Re: SMTP Mail Server Help

Mon Mar 07, 2016 12:01 pm

I have error in command line mail plz kindly help me... [ mail: cannot send message: Process exited with a non-zero status ]

Yunicx
Posts: 5
Joined: Tue Mar 08, 2016 4:24 pm

Re: SMTP Mail Server Help

Tue Mar 08, 2016 4:36 pm

I am not a programmer and have been struggling a lot with trying things/settings. I ran into the same problem as the other guys on this page and still nothing helped me.
Since I think the problem was at the end of Google's security policies, I kept digging and tried something like access by a new device or application, which can be found on:
https://accounts.google.com/DisplayUnlockCaptcha
After I enabled it, the emails went out ! In a way that setting didn't make any sense to me, after checking all other settings on google's help pages.

Anyways, I came across another problem that I found on the "https://accounts.google.com/DisplayUnlockCaptcha" page.

When I copy commands from that page to the LXTerminal window, they cannot be executed properly due to an encoding problem.
In the echo "Test text" command, the LXTerminal shows the 66 and 99 apostrophes while they have to be the two double apostrophes.
I'm sorry I can't explain it differently, but make sure they are " symbols and NOT the curved apostrophes. It is so damn sensitive and that's why I'm not a programmer. These things drive me crazy. I just wanted to shout this out to you guys struggling with it like I did ;-)

Things are finally working the way they should. Everyone thanks for the tips and advice!

Slackware
Posts: 125
Joined: Mon Jan 18, 2016 3:45 pm

Re: SMTP Mail Server Help

Thu Mar 10, 2016 9:41 pm

open Telnet on port 25 and talk directly with email server to see if it is working at all.
but you should have something in the syslog and message log files. An error return should add something in there.

buzzshot69
Posts: 1
Joined: Sat Apr 09, 2016 5:11 pm

Re: SMTP Mail Server Help

Sat Apr 09, 2016 5:21 pm

I was having the same problem so i went in to the log and copy the http and googled it. it brought me to a google help sit and told me to Change account access for less secure apps and turn it on, once i did that i could send emails. Also make sure if your Password has Capitals to put the same under e i did that i could send emails. Also make sure if your Password has Capitals to put the same under Authpass the same way.
Hope this helps

Vivid Haze
Posts: 1
Joined: Fri Aug 26, 2016 10:38 am

Re: SMTP Mail Server Help

Fri Aug 26, 2016 10:40 am

Yunicx wrote: Since I think the problem was at the end of Google's security policies, I kept digging and tried something like access by a new device or application, which can be found on:
https://accounts.google.com/DisplayUnlockCaptcha
After I enabled it, the emails went out
This solved it for me! Many thanks, legend! 8-)

Alle_Melzi
Posts: 1
Joined: Sun Aug 28, 2016 4:04 pm

Re: SMTP Mail Server Help

Sun Aug 28, 2016 4:06 pm

I had similar problem but I fixed using the User name without the @gmail.com like this:

boozo
Posts: 1
Joined: Thu Oct 27, 2016 11:04 am

Re: SMTP Mail Server Help

Thu Oct 27, 2016 11:12 am

I've had a similar problem. Do not use the hash symbol in password phrase. Maybe it gets interpreted as comment line.

Also putting quotes around the password did not help!

The solution was to use a password without the special hash character.

Return to “Networking and servers”

Who is online

Users browsing this forum: Bing [Bot] and 7 guests