qtxradio
Posts: 9
Joined: Thu Aug 01, 2013 10:55 am
Location: Leeds
Contact: Website

smtp configuration

Tue Feb 14, 2017 2:26 pm

I have had smtp mail working in the past but now cannot get mail to sent from an RPi when using a new gmail account
This new account is just for the RPi because I am reluctant to put my personal email credentials into the ssmtp.conf file.

File ssmtp.conf: (private stuff obscured)
Debug=YES
root=[email protected]
mailhub=smtp.gmail.com:587
AuthUser=[email protected]
AuthPass=SomePass
AuthMethod=LOGIN
UseTLS=YES
UseSTARTTLS=YES
hostname=RPi5
FromLineOverride=YES

File revaliases:
root:[email protected]:smtp.gmail.com:587
pi:[email protected]:smtp.gmail.com:587

I also configured /etc/aliases, but not clear if this is needed:
mailer-daemon: postmaster
postmaster: root
noc: root
security: root
root: pi
pi: [email protected]

If I use the credentials for my personal gmail account then the simple
echo "message" | mail -s "subject" [email protected]
works.

But if I then change the credentials, in all 3 files to the newly created account it does not.
In that case the mail command exits with a non-zero error code and the log file just says that the credentials were not accepted. I have added the debug option, and the resulting log sheds no more light on the issue:
Feb 14 10:50:06 raspberrypi sSMTP[6826]: Set Root="[email protected]"
... various SET commands as per ssmtp.conf
Feb 14 10:50:06 raspberrypi sSMTP[6826]: Set MailHub="smtp.gmail.com"
Feb 14 10:50:06 raspberrypi sSMTP[6826]: via SMTP Port Number="587"
Feb 14 10:50:06 raspberrypi sSMTP[6826]: Creating SSL connection to host
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 220 smtp.gmail.com ESMTP p49sm287688wrb.10 - gsmtp
Feb 14 10:50:06 raspberrypi sSMTP[6826]: EHLO RPi5
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 250 SMTPUTF8
Feb 14 10:50:06 raspberrypi sSMTP[6826]: STARTTLS
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 220 2.0.0 Ready to start TLS
Feb 14 10:50:06 raspberrypi sSMTP[6826]: SSL connection using RSA_AES_128_CBC_SHA1
Feb 14 10:50:06 raspberrypi sSMTP[6826]: EHLO RPi5
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 250 SMTPUTF8
Feb 14 10:50:06 raspberrypi sSMTP[6826]: AUTH LOGIN
Feb 14 10:50:06 raspberrypi sSMTP[6826]: <redacted>
Feb 14 10:50:06 raspberrypi sSMTP[6826]: <redacted>
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 535 5.7.8 https://support.google.com/mail/?p=BadCredentials p49sm287688wrb.10 - gsmtp
Feb 14 10:50:06 raspberrypi sSMTP[6826]: Authorization failed (535 5.7.8 https://support.google.com/mail/?p=BadCredentials p49sm287688wrb.10 - gsmtp)

The new account has the enable less secure apps settings on and I have enabled POP3 and IMAP just because those are the settings on my personal account as well. I can log into the new account, so the credentials are right, and I can send and receive mail from/to this new account. It looks like the login is being attempted and rejected, but I have no idea why. So have I missed something in the RPi configuration or is there any change in policy from google regarding new accounts?

I have done many searches, but not found anything that I am doing wrong, I am stuck so any help appreciated.

epoch1970
Posts: 3864
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: smtp configuration

Tue Feb 14, 2017 7:43 pm

I don't use ssmtp but msmtp, and it works with gmail.
I do use the "App passwords" Google thing on the account that sends the emails, to authenticate the machine. The generated key is used as password, instead of the account password.
Many of my Pis send email to/under the same account, each machine has its own "app password" defined.

My config:

Code: Select all

$ cat /etc/msmtprc 
# Accounts will inherit settings from this section
defaults
auth            on
tls             on
tls_certcheck   off
# tls_trust_file  /etc/ssl/certs/ca-certificates.crt
logfile /var/log/msmtp.log
aliases /etc/aliases

# A first gmail address
account   gmail
host      smtp.gmail.com
port      587
from      [email protected]
user      [email protected]
# Acct password
#password xxxxxx
# App password for Pi
password dfr123jgf421xgu

# Add more if you want

# Set a default account
account default : gmail

$ cat /etc/aliases 
# /etc/aliases
mailer-daemon: [email protected]
postmaster: [email protected]
nobody: [email protected]
hostmaster: [email protected]
usenet: [email protected]
news: [email protected]
webmaster: [email protected]
www: [email protected]
ftp: [email protected]
abuse: [email protected]
noc: [email protected]
security: [email protected]
root: [email protected]

$ sudo dpkg -l |grep msm
ii  msmtp                            1.4.32-2+b1                     armhf        light SMTP client with support for server profiles
ii  msmtp-mta                        1.4.32-2                        all          light SMTP client with support for server profiles - the regular MTA
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

pcmanbob
Posts: 7255
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: smtp configuration

Wed Feb 15, 2017 4:19 pm

qtxradio wrote:I have had smtp mail working in the past but now cannot get mail to sent from an RPi when using a new gmail account
This new account is just for the RPi because I am reluctant to put my personal email credentials into the ssmtp.conf file.

File ssmtp.conf: (private stuff obscured)
Debug=YES
root=[email protected]
mailhub=smtp.gmail.com:587
AuthUser=[email protected]
AuthPass=SomePass
AuthMethod=LOGIN
UseTLS=YES
UseSTARTTLS=YES
hostname=RPi5
FromLineOverride=YES

File revaliases:
root:[email protected]:smtp.gmail.com:587
pi:[email protected]:smtp.gmail.com:587

I also configured /etc/aliases, but not clear if this is needed:
mailer-daemon: postmaster
postmaster: root
noc: root
security: root
root: pi
pi: [email protected]

If I use the credentials for my personal gmail account then the simple
echo "message" | mail -s "subject" my[email protected]
works.

But if I then change the credentials, in all 3 files to the newly created account it does not.
In that case the mail command exits with a non-zero error code and the log file just says that the credentials were not accepted. I have added the debug option, and the resulting log sheds no more light on the issue:
Feb 14 10:50:06 raspberrypi sSMTP[6826]: Set Root="[email protected]"
... various SET commands as per ssmtp.conf
Feb 14 10:50:06 raspberrypi sSMTP[6826]: Set MailHub="smtp.gmail.com"
Feb 14 10:50:06 raspberrypi sSMTP[6826]: via SMTP Port Number="587"
Feb 14 10:50:06 raspberrypi sSMTP[6826]: Creating SSL connection to host
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 220 smtp.gmail.com ESMTP iiiii.10 - gsmtp
Feb 14 10:50:06 raspberrypi sSMTP[6826]: EHLO RPi5
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 250 SMTPUTF8
Feb 14 10:50:06 raspberrypi sSMTP[6826]: STARTTLS
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 220 2.0.0 Ready to start TLS
Feb 14 10:50:06 raspberrypi sSMTP[6826]: SSL connection using RSA_AES_128_CBC_SHA1
Feb 14 10:50:06 raspberrypi sSMTP[6826]: EHLO RPi5
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 250 SMTPUTF8
Feb 14 10:50:06 raspberrypi sSMTP[6826]: AUTH LOGIN
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 334
Feb 14 10:50:06 raspberrypi sSMTP[6826]: =
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 33
Feb 14 10:50:06 raspberrypi sSMTP[6826]:=
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 535 5.7.8 https://support.google.com/mail/?p=BadCredentials p49sm287688wrb.10 - gsmtp
Feb 14 10:50:06 raspberrypi sSMTP[6826]: Authorization failed (535 5.7.8 https://support.google.com/mail/?p=BadCredentials p49sm287688wrb.10 - gsmtp)

The new account has the enable less secure apps settings on and I have enabled POP3 and IMAP just because those are the settings on my personal account as well. I can log into the new account, so the credentials are right, and I can send and receive mail from/to this new account. It looks like the login is being attempted and rejected, but I have no idea why. So have I missed something in the RPi configuration or is there any change in policy from google regarding new accounts?

I have done many searches, but not found anything that I am doing wrong, I am stuck so any help appreciated.

Hi.

The only difference I can see between your config and my config is, I don't have this line. AuthMethod=LOGIN.
also check you credentials as it seems to be saying they are wrong but don't use any special characters like £$%&* in your password, I found ssmtp was not able to sign in if you used anything other than letters and numbers, caps are ok.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

qtxradio
Posts: 9
Joined: Thu Aug 01, 2013 10:55 am
Location: Leeds
Contact: Website

Re: smtp configuration

Wed Feb 15, 2017 6:56 pm

Thank you for the help provided. I have stumbled on a solution, but still no idea why one address works while the other does not. Note, I do have only letters and numbers in the passwords.

Anyway, I have found that if I omit the @gmail.com from the AuthUser entry for the new email address it does now work. Similarly, for my private address, even though it works with the @gmail.com anyway, leaving it off also works. Still a mystery what is going on, all the guides and tutorials I have found advocate having the @gmail.com in that line, but it certainly works without.

Not 100% satisfactory to not know why, but a valid solution is just that, and thankful for it. :D

thanks R

pcmanbob
Posts: 7255
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: smtp configuration

Wed Feb 15, 2017 10:01 pm

qtxradio wrote:Thank you for the help provided. I have stumbled on a solution, but still no idea why one address works while the other does not. Note, I do have only letters and numbers in the passwords.

Anyway, I have found that if I omit the @gmail.com from the AuthUser entry for the new email address it does now work. Similarly, for my private address, even though it works with the @gmail.com anyway, leaving it off also works. Still a mystery what is going on, all the guides and tutorials I have found advocate having the @gmail.com in that line, but it certainly works without.

Not 100% satisfactory to not know why, but a valid solution is just that, and thankful for it. :D

thanks R
Glad you found the answer, that would match the way you sign in when using a browser then you don't need the @gmail.com bit any more just the first part of your email address.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

grantdraper
Posts: 1
Joined: Sat Dec 22, 2018 4:36 pm

Re: smtp configuration

Sat Dec 22, 2018 4:57 pm

@qtxradio

Make sure you have changed the password for the account you used below, your email and password are just base64 encoded. I wanted to let you know privately but could not find any way to message you.

Feb 14 10:50:06 raspberrypi sSMTP[6826]: Set Root="[email protected]"
... various SET commands as per ssmtp.conf
Feb 14 10:50:06 raspberrypi sSMTP[6826]: Set MailHub="smtp.gmail.com"
Feb 14 10:50:06 raspberrypi sSMTP[6826]: via SMTP Port Number="587"
Feb 14 10:50:06 raspberrypi sSMTP[6826]: Creating SSL connection to host
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 220 smtp.gmail.com ESMTP hhhhh.10 - gsmtp
Feb 14 10:50:06 raspberrypi sSMTP[6826]: EHLO RPi5
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 250 SMTPUTF8
Feb 14 10:50:06 raspberrypi sSMTP[6826]: STARTTLS
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 220 2.0.0 Ready to start TLS
Feb 14 10:50:06 raspberrypi sSMTP[6826]: SSL connection using RSA_AES_128_CBC_SHA1
Feb 14 10:50:06 raspberrypi sSMTP[6826]: EHLO RPi5
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 250 SMTPUTF8
Feb 14 10:50:06 raspberrypi sSMTP[6826]: AUTH LOGIN

pcmanbob
Posts: 7255
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: smtp configuration

Sat Dec 22, 2018 6:20 pm

grantdraper wrote:
Sat Dec 22, 2018 4:57 pm
@qtxradio

Make sure you have changed the password for the account you used below, your email and password are just base64 encoded. I wanted to let you know privately but could not find any way to message you.

Feb 14 10:50:06 raspberrypi sSMTP[6826]: Set Root="[email protected]"
... various SET commands as per ssmtp.conf
Feb 14 10:50:06 raspberrypi sSMTP[6826]: Set MailHub="smtp.gmail.com"
Feb 14 10:50:06 raspberrypi sSMTP[6826]: via SMTP Port Number="587"
Feb 14 10:50:06 raspberrypi sSMTP[6826]: Creating SSL connection to host
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 220 smtp.gmail.com ESMTP p49sm287. ....10 - gsmtp
Feb 14 10:50:06 raspberrypi sSMTP[6826]: EHLO RPi5
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 250 SMTPUTF8
Feb 14 10:50:06 raspberrypi sSMTP[6826]: STARTTLS
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 220 2.0.0 Ready to start TLS
Feb 14 10:50:06 raspberrypi sSMTP[6826]: SSL connection using RSA_AES_128_CBC_SHA1
Feb 14 10:50:06 raspberrypi sSMTP[6826]: EHLO RPi5
Feb 14 10:50:06 raspberrypi sSMTP[6826]: 250 SMTPUTF8
Feb 14 10:50:06 raspberrypi sSMTP[6826]: AUTH LOGIN
For you actually read the thread properly you would have seen the problem was solved feb 2017.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: smtp configuration

Sun Dec 23, 2018 12:18 pm

pcmanbob wrote:
Sat Dec 22, 2018 6:20 pm
grantdraper wrote:
Sat Dec 22, 2018 4:57 pm
Make sure you have changed the password for the account you used below, your email and password are just base64 encoded. I wanted to let you know privately but could not find any way to message you.
For you actually read the thread properly you would have seen the problem was solved feb 2017.
That might the case, but he has a valid point.

If the OP sees this they might want to change their password. I've also reported to the mods in case they want to tidy it up (which might have been the best approach for whoever spotted this before)

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12400
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: smtp configuration

Sun Dec 23, 2018 6:44 pm

Tidying up makes No sense, what is posted on the internet is cached, and captured, and will stay on the internet.
Please update Your password.

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: smtp configuration

Mon Dec 24, 2018 12:18 am

mahjongg wrote:
Sun Dec 23, 2018 6:44 pm
Tidying up makes No sense, what is posted on the internet is cached, and captured, and will stay on the internet.
Please update Your password.
Whilst it may be cached, I don't think that's really a reason not to do what you can to improve matters when it's been brought to the mods attention. Considering the OP hasn't been here since early 2017 (I tried to look earlier but the forum was restricting such stuff due to load) expecting them to update their password is a long shot.

Could this be a considered a breach of GDPR? Might be an interesting question for the ICO!

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12400
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: smtp configuration

Wed Dec 26, 2018 4:34 pm

I “demolished” all texts in these posts, and replies that looked like they could’ve been cyphers, or passwords.

User avatar
grega
Site Admin
Posts: 45
Joined: Thu Feb 09, 2017 4:50 pm

Re: smtp configuration

Fri Jan 04, 2019 1:29 pm

Remaining base64-encoded credentials have been redacted and relevant URLs submitted to Google to request removal from their indexes.

Thanks for the heads up mfa298

Return to “General discussion”