RiccardOne
Posts: 2
Joined: Sun Feb 14, 2016 4:55 pm

Mail on Buster

Sun Jun 30, 2019 7:34 am

On a fresh installed Buster OS on a Raspi zero I can't send mail, I get this error:
mail: cannot send message: Process exited with a non-zero status

On a Raspi zero with Stretch and the same mail configuration the mail works.
Anybody has the same issue? suggestions?
Riccardo

Here is my setup:
Loading the packages
sudo apt-get install ssmtp
sudo apt-get install mailutils mpack

Setting up the defaults for SSMTP
sudo nano /etc/ssmtp/ssmtp.conf

1. Now edit the fields:
root=postmaster
mailhub=smtp.gmail.com:587
hostname=rpi0c
AuthUser=youruserid@gmail.com
AuthPass=userpass
FromLineOverride=YES
UseSTARTTLS=YES

Using Email Now
sudo reboot
echo "sample text" | mail -s "Subject" username@domain.tld

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

Re: Mail on Buster

Sun Jun 30, 2019 9:07 am

Yes SSMTP does not seem to work on buster, but I can send email using the same gmail credentials using smtplib in a python program, So there must be an incomparability with SSMTP or one of it dependants in buster, but I have no idea what.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

HMo
Posts: 1
Joined: Sun Jun 30, 2019 1:36 pm

Re: Mail on Buster

Sun Jun 30, 2019 1:44 pm

I have made the same observations with Debian / Raspbian – Buster and ssmtp.

Then, I have followed this Wiki Ubuntu about msmtp
https://doc.ubuntu-fr.org/msmtp and
https://doc.ubuntu-fr.org/tutoriel/comm ... e_commande.

Reboot and tested with mail like this :

echo 'message' | mail user@domain.com

I could reuse my programs without changes.

harisb
Posts: 1
Joined: Fri Jul 05, 2019 3:40 pm

Re: Mail on Buster

Fri Jul 05, 2019 3:59 pm

Hi,
Below are my own observations, in case they can help.

I added DEBUG=YES in ssmtp.conf and examined the differences in /var/etc/mail.log
between two identically configured raspberry boxes. In both boxes ssmtp was configured
to send email via gmail.

- Box A with raspberry stretch (ssmtp working ok)
- Box B with raspberry buster (ssmtp not working)

I observed that after trying to send an email from both boxes,
in Box A (the mail went through ok) I had the following log line in mail.log:
SSL connection using RSA_AES_128_CBC_SHA1

In Box B (sending the mail failed) the above log line had been replaced with:
SSL connection using ECDHE_RSA_AES_256_GCM_SHA384

So, it seams that, in buster, ssmpt tries to use a different ciffer.

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

Re: Mail on Buster

Sun Jul 07, 2019 11:26 am

HMo wrote:
Sun Jun 30, 2019 1:44 pm

Then, I have followed this Wiki Ubuntu about msmtp
https://doc.ubuntu-fr.org/msmtp and
https://doc.ubuntu-fr.org/tutoriel/comm ... e_commande.
Thanks HMo for the links
got my pi email working on buster , with a bit of help from google translate.
:D :D :D :D :D
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

paulv
Posts: 563
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: Mail on Buster

Wed Jul 10, 2019 1:03 pm

Just to follow-up on the previous posts, ssmtp is deprecated on Buster, it is no longer maintained.
(typical experience with a major system change..., sigh!)

The more modern and supported alternative is msmtp.

You can install that package with:

Code: Select all

sudo apt-get install msmtp msmtp-mta
The configuration file is located here : /etc/msmtprc
Strangely enough, it is empty with no clues, which is different from the good old ssmtp.conf file.
However, there is a very large description with details if you use

Code: Select all

man msmtp
For gmail accounts, these are the specific elements you should put into /etc/msmtprc:

Code: Select all

# Generics
defaults
auth           on
tls            on
# following is different from ssmtp:
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# user specific log location, otherwise use /var/log/msmtp.log, however, 
# this will create an access violation if you are user pi, and have not changes the access rights
logfile        ~/.msmtp.log

# Gmail specifics
account        gmail
host           smtp.gmail.com
port           587

from          root@raspi-buster
user           your-gmail-accountname@gmail.com
password       your-gmail-account-password

# Default
account default : gmail
You can test this with:

Code: Select all

echo 'your message' | msmtp destination-email-address@gmail.com
I have not yet found a way to set the subject, there is no -s flag either.

However, if you also install mailutils:

Code: Select all

sudo apt-get install mailutils
Then these two work again:

Code: Select all

echo 'message' | mail -s "raspi-buster" destination-email-address@gmail.com
echo 'message' | sendmail destination-email-address@gmail.com
Unfortunately, my watchdog setup nor cron get the mail out. From the error message in /var/log/mail.err it seems that there is an incompatibility with this setup, and the previously established mail setup.

Hopefully somebody that is more adept can help out to get this fixed.


Hope this helps to get mail going on buster.

Enjoy!
Last edited by paulv on Fri Jul 12, 2019 1:15 pm, edited 3 times in total.

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

Re: Mail on Buster

Wed Jul 10, 2019 1:15 pm

You can use both mailutils and mpack with msmtp just as you did with ssmtp.

So any scripts that you have used before with ssmtp, mailutils or mpack will work just the same using msmtp, mailutils or mpack
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

paulv
Posts: 563
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: Mail on Buster

Wed Jul 10, 2019 2:46 pm

pcmanbob,

Did you try to get mails out from cron or watchdog?

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

Re: Mail on Buster

Wed Jul 10, 2019 2:59 pm

I have several pi's sending emails using cron and also had error messages from cron, if you set up the mailto line in cron, seeing as I am using mail or mpack to send mail from cron I don't see why it should not work with msmtp in exactly the same way.

I would normally just write a short bash script to send the email with what ever information is required
( for example the current IP address of the pi ) and then just call that using cron,

not forgetting that cron runs early in the boot process so if sending email at boot you need to add a delay before trying to send the email to allow networking to be up.

I have never used watchdog so can't comment on that.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

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

Re: Mail on Buster

Thu Jul 11, 2019 8:12 pm

In case it helps. This comes from a Jessie machine working in the field with msmtp as mailer.

Code: Select all

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 8.0 (jessie)
Release:	8.0
Codename:	jessie

$ msmtp --version
msmtp version 1.4.32
Platform: arm-unknown-linux-gnueabihf
TLS/SSL library: GnuTLS
Authentication library: GNU SASL
Supported authentication methods:
plain scram-sha-1 cram-md5 external digest-md5 login ntlm 
IDN support: enabled
NLS: enabled, LOCALEDIR is /usr/share/locale
Keyring support: none
System configuration file name: /etc/msmtprc
User configuration file name: /root/.msmtprc

Copyright (C) 2014 Martin Lambers and others.
...
/etc/aliases:

Code: Select all

$ cat /etc/aliases 
mailer-daemon: postmaster@localhost
postmaster: root@localhost
nobody: root@localhost
hostmaster: root@localhost
usenet: root@localhost
news: root@localhost
webmaster: root@localhost
www: root@localhost
ftp: root@localhost
abuse: root@localhost
noc: root@localhost
security: root@localhost
root: randomuser@gmail.com
/etc/msmtprc:

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 admin_mail
host smtp.gmail.com
port 587
from root@thishostname
user randomuser@gmail.com
# App password for this host
# Defined by user randomuser in their G account prefs
# (login to G and add other machines/apps)
password tokengeneratedbygmailforthisapp

# Add more accounts if you want

# Set a default account
account default : admin_mail
The machine has linux watchdog installed and basically the machine (watchdog) sends at least an email per day. I will post a few bits of possibly relevant config in paulv's thread on watchdog. Nothing much.

HTH
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

paulv
Posts: 563
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: Mail on Buster

Fri Jul 12, 2019 11:35 am

Epoch1970,

Your help is very much appreciated. Merci bien!

First off, I found that you have to use the TLS method the way I used it above, if I use it without as you have, there is an error generated.

With your other information, I think I found the problem with Buster.
There is no /etc/aliases file.

A default installation on one of my Jessie RPi's produces this:

Code: Select all

# /etc/aliases
mailer-daemon: postmaster
postmaster: root
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root
So on Buster, the system has no idea where to send stuff to.
Oversight or bug?

To test this, I added the above entries to /etc/aliases, and as a last line:

Code: Select all

root: your_email_address@gmail.com
To cron I added this:

Code: Select all

MAILTO=root


17 14 * * * /bin/sh /home/pi/whatever
Just set your own time instead of 17 14, and this will trigger an email to be sent by cron coming from pi-user@raspi-host-name because /home/pi/whatever does not exist. You could also use

Code: Select all

MAILTO="your-email-address@gmail.com"
BTW, I still can't get the watchdog package to mail, or log...

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

Re: Mail on Buster

Fri Jul 12, 2019 5:36 pm

paulv wrote:
Fri Jul 12, 2019 11:35 am
So on Buster, the system has no idea where to send stuff to.
Oversight or bug?
I tend to port working recipes from machine to machine until it breaks, my encounter with msmtp occurred many years ago.
If you lookup the list of files provided by packages msmtp or msmtp-mta you can find /usr/sbin/sendmail and newaliases (in msmtp-mta) but a template for /etc/aliases is nowhere to be found.
I don't know which package provides /etc/aliases on Debian, if any. Not sendmail-base, as far as I can see. Perhaps some greybeards made an executive decision...
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Daddyfix
Posts: 52
Joined: Sun Dec 09, 2012 2:13 pm
Location: Sudbury, Ontario

Re: Mail on Buster

Sun Aug 11, 2019 11:19 pm

paulv wrote:
Wed Jul 10, 2019 1:03 pm
Just to follow-up on the previous posts, ssmtp is deprecated on Buster, it is no longer maintained.
(typical experience with a major system change..., sigh!)

The more modern and supported alternative is msmtp.

You can install that package with:

Code: Select all

sudo apt-get install msmtp msmtp-mta
The configuration file is located here : /etc/msmtprc
Strangely enough, it is empty with no clues, which is different from the good old ssmtp.conf file.
However, there is a very large description with details if you use

Code: Select all

man msmtp
For gmail accounts, these are the specific elements you should put into /etc/msmtprc:

Code: Select all

# Generics
defaults
auth           on
tls            on
# following is different from ssmtp:
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# user specific log location, otherwise use /var/log/msmtp.log, however, 
# this will create an access violation if you are user pi, and have not changes the access rights
logfile        ~/.msmtp.log

# Gmail specifics
account        gmail
host           smtp.gmail.com
port           587

from          root@raspi-buster
user           your-gmail-accountname@gmail.com
password       your-gmail-account-password

# Default
account default : gmail
You can test this with:

Code: Select all

echo 'your message' | msmtp destination-email-address@gmail.com
I have not yet found a way to set the subject, there is no -s flag either.

However, if you also install mailutils:

Code: Select all

sudo apt-get install mailutils
Then these two work again:

Code: Select all

echo 'message' | mail -s "raspi-buster" destination-email-address@gmail.com
echo 'message' | sendmail destination-email-address@gmail.com
Unfortunately, my watchdog setup nor cron get the mail out. From the error message in /var/log/mail.err it seems that there is an incompatibility with this setup, and the previously established mail setup.

Hopefully somebody that is more adept can help out to get this fixed.


Hope this helps to get mail going on buster.

Enjoy!
Thank you. This worked like a charm for me!

Aroa
Posts: 2
Joined: Tue Sep 03, 2019 10:21 am

Re: Mail on Buster

Tue Sep 03, 2019 10:34 am

Hello Im new in this world, I have a rapsberry pi3 with debian y want to send email.
I followed this steps :

Daddyfix wrote:
paulv wrote:
Wed Jul 10, 2019 1:03 pm
Just to follow-up on the previous posts, ssmtp is deprecated on Buster, it is no longer maintained.
(typical experience with a major system change..., sigh!)

The more modern and supported alternative is msmtp.

You can install that package with:

Code: Select all

sudo apt-get install msmtp msmtp-mta
The configuration file is located here : /etc/msmtprc
Strangely enough, it is empty with no clues, which is different from the good old ssmtp.conf file.
However, there is a very large description with details if you use

Code: Select all

man msmtp
For gmail accounts, these are the specific elements you should put into /etc/msmtprc:

Code: Select all

# Generics
defaults
auth           on
tls            on
# following is different from ssmtp:
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# user specific log location, otherwise use /var/log/msmtp.log, however, 
# this will create an access violation if you are user pi, and have not changes the access rights
logfile        ~/.msmtp.log

# Gmail specifics
account        gmail
host           smtp.gmail.com
port           587

from          root@raspi-buster
user           your-gmail-accountname@gmail.com
password       your-gmail-account-password

# Default
account default : gmail
You can test this with:

Code: Select all

echo 'your message' | msmtp destination-email-address@gmail.com
I have not yet found a way to set the subject, there is no -s flag either.

However, if you also install mailutils:

Code: Select all

sudo apt-get install mailutils
Then these two work again:

Code: Select all

echo 'message' | mail -s "raspi-buster" destination-email-address@gmail.com
echo 'message' | sendmail destination-email-address@gmail.com
Unfortunately, my watchdog setup nor cron get the mail out. From the error message in /var/log/mail.err it seems that there is an incompatibility with this setup, and the previously established mail setup.

Hopefully somebody that is more adept can help out to get this fixed.


Hope this helps to get mail going on buster.

Enjoy!
Thank you. This worked like a charm for me!


but return to me pi@raspberrypi:~ $ sudo echo 'your message' | msmtp asanzmaroto@gmail.com
msmtp: /home/pi/.msmtprc: contains secrets and therefore must have no more than user read/write permissions

I give the permision with chmon 777 /home/pi/.msmtprc

pi@raspberrypi:~ $ ls -l /home/pi/.msmtprc
-rwxrwxrwx 1 pi pi 1378 Sep 2 18:11 /home/pi/.msmtprc


But the problem is still.
Can somebody help me please?
Thank you so much

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

Re: Mail on Buster

Tue Sep 03, 2019 1:36 pm

Aroa wrote:
Tue Sep 03, 2019 10:34 am
but return to me pi@raspberrypi:~ $ sudo echo 'your message' | msmtp asanzmaroto@gmail.com
msmtp: /home/pi/.msmtprc: contains secrets and therefore must have no more than user read/write permissions

I give the permision with chmon 777 /home/pi/.msmtprc

pi@raspberrypi:~ $ ls -l /home/pi/.msmtprc
-rwxrwxrwx 1 pi pi 1378 Sep 2 18:11 /home/pi/.msmtprc


But the problem is still.
Can somebody help me please?
Thank you so much
Hi.

So first question is why are you using " sudo " to call your send mail line ?

You don't need sudo you can send it as the pi user.

Secondly you are getting the message about user permissions because you should only have one user who can read/write the config file for msmtp, so you should be using chmon 700 /home/pi/.msmtprc so that only the pi user has read/write access to the config file.

As always read the error message it tells you what the problem is " contains secrets and therefore must have no more than user read/write permissions "

If you want msmtp to be usable by all users then you need to put the config file in " /etc " and not " /home/pi/ "
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Aroa
Posts: 2
Joined: Tue Sep 03, 2019 10:21 am

Re: Mail on Buster

Tue Sep 03, 2019 2:55 pm

pcmanbob wrote:
Aroa wrote:
Tue Sep 03, 2019 10:34 am
but return to me pi@raspberrypi:~ $ sudo echo 'your message' | msmtp asanzmaroto@gmail.com
msmtp: /home/pi/.msmtprc: contains secrets and therefore must have no more than user read/write permissions

I give the permision with chmon 777 /home/pi/.msmtprc

pi@raspberrypi:~ $ ls -l /home/pi/.msmtprc
-rwxrwxrwx 1 pi pi 1378 Sep 2 18:11 /home/pi/.msmtprc


But the problem is still.
Can somebody help me please?
Thank you so much
Hi.

So first question is why are you using " sudo " to call your send mail line ?

You don't need sudo you can send it as the pi user.

Secondly you are getting the message about user permissions because you should only have one user who can read/write the config file for msmtp, so you should be using chmon 700 /home/pi/.msmtprc so that only the pi user has read/write access to the config file.

As always read the error message it tells you what the problem is " contains secrets and therefore must have no more than user read/write permissions "

If you want msmtp to be usable by all users then you need to put the config file in " /etc " and not " /home/pi/ "

Thank you so much. It is solve
You are right, i didnt need sudo before.
i change chmon 700 /home/pi/.msmtprc and also i move the config file in "/etc"
Everything is working great!!!! Thanks :D :D :D :D :D

turbo2ltr
Posts: 5
Joined: Fri Jun 29, 2012 5:52 pm

Re: Mail on Buster

Sun Feb 16, 2020 12:36 am

Some additional info for people that find this.

msmtp is expecting a fully formatted complete email with RFC5322 compliant headers. (which is why there is no option to set a subject)

I use a line similar to this in a script called by a cron to send an alert email.

Code: Select all

printf "To: email@domain.com\nFrom: ProperName <email2@domain.com>\nSubject: This is my subject\n\nThis is my message" | msmtp email@domainc.com

User avatar
RDK
Posts: 303
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Mail on Buster

Sun Feb 23, 2020 8:19 am

For those that arrive here in trying to setup MSMTP for e-mail on Buster. I have it running on several Buster Pi's (B+, 3B+ and 4B) after following much of the information in this thread and some other research.
Here are my config files:
/etc/msmtprc

Code: Select all

defaults
auth           on
tls            on
# following is different from ssmtp:
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# user specific log location, otherwise use /var/log/msmtp.log, however,
# this will create an access violation if you are user pi, and have not changes$
#logfile        ~/.msmtp.log
logfile         /var/log/msmtp/msmtp.log
aliases        /etc/aliases
# Gmail specifics
account        gmail
host           smtp.gmail.com
port           587
from          me@gmail.com
user          me@gmail.com
password      my#@%$*pw
# Default
account default : gmail
and
/etc/aliases

Code: Select all

# Send root to
root: me@somewhere.com
# Send cron to
cron: me@somewhere.com
# Send everything else to
default: me@somewhere.com
The following works to email a message:

Code: Select all

 echo "MSMTP Test Messsage" | mail -s "MSmpt Msg" me@somewhere.com
One thing I have noticed which is different from SSMTP on my other Pi's/OS's is that before when the e-mal arrived the FROM displayed both the e-mail address (me@gmail.com) AND the "friendly name" which g-mail associated with that address, ie "Sam Smith <me@gmail.com> ". Now usng MSMTP what I get is this "<me@gmail.com", but no "friendly name". I'm not aware of anything I did special with SSMTP. Can anyone suggest how I can again get the "friendly name"?
Thanks....RDK

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

Re: Mail on Buster

Sun Feb 23, 2020 12:43 pm

Looking at the mail log you should find that when using the mail command to send mail with msmtp that the FROM address is actually set to pi@hostname , so for example one of my pi this is " pi@Busterpi "

But for some reason Gmail just seems to ignore this when using msmtp, I have even tried using the -F option to change the FROM to something else using the msmtp command to send mail directly and even though the FROM is changed to what ever I set it to, it never appears on the email.

I have tried lots of examples I found on the web and non have worked when using msmtp , mail or mpack to send emails , some even broke the email so it would not send.

So it seems to me that using msmtp with a Gmail account you are stuck with the From just containing " mail@gmail.com(mail@gmail.com) "

If I ever find a way I will of course post it here.

edit.....
I have also found that when using smtplib to send mail directly from a python program even though the FROM is set to something other than the email address Gmail still only displays the From just containing " mail@gmail.com(mail@gmail.com) "
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
RDK
Posts: 303
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Mail on Buster

Sun Feb 23, 2020 3:11 pm

PCMANBOB.....Thanks, I'll stop looking and worrying about it....RDK

witty
Posts: 34
Joined: Sat Oct 31, 2015 5:33 pm

Re: Mail on Buster

Tue Apr 28, 2020 11:15 pm

paulv wrote:
Wed Jul 10, 2019 1:03 pm

Code: Select all

# user specific log location, otherwise use /var/log/msmtp.log, however, 
# this will create an access violation if you are user pi, and have not changes the access rights
logfile        ~/.msmtp.log
Unfortunately, my watchdog setup nor cron get the mail out. From the error message in /var/log/mail.err it seems that there is an incompatibility with this setup, and the previously established mail setup.
get rid of access violation for /var/log/msmtp.log:

Code: Select all

sudo touch /var/log/msmtp.log
sudo chown mail:mail /var/log/msmtp.log
sudo chmod 660 /var/log/msmtp.log
adduser pi mail
#log out and in again, to make new group-membership effective
receive emails from cron:
add the following line to your crontab

Code: Select all

MAILTO=mymail@mydomain.com
receive emails from watchdog:
add the following line to your watchdog.sh

Code: Select all

mailto=mymail@mydomain.com

petike779
Posts: 15
Joined: Sat Nov 09, 2019 5:24 pm

Re: Mail on Buster

Sat May 02, 2020 10:23 am

Hi guys
I am struggling to get working this email sending On Pi4.
First of all on my buster I don't have this 2 files: /etc/msmtprc and /etc/aliases
I followed the installation, was successful.

Code: Select all

pi@raspberrypipeti:/ $ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 10 (buster)
Release:	10
Codename:	buster

Code: Select all

pi@raspberrypipeti:/ $ msmtp --version
msmtp version 1.8.3
Platform: arm-unknown-linux-gnueabihf
TLS/SSL library: GnuTLS
Authentication library: GNU SASL
Supported authentication methods:
plain scram-sha-1 external gssapi cram-md5 digest-md5 login ntlm 
IDN support: enabled
NLS: enabled, LOCALEDIR is /usr/share/locale
Keyring support: none
System configuration file name: /etc/msmtprc
User configuration file name: /home/pi/.msmtprc
Really stucked because I don't know what I am doing wrong...
Please advice.
Thanks , Peter

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

Re: Mail on Buster

Sat May 02, 2020 12:10 pm

You did nothing wrong , you have to create these 2 files using a simple file editor like nano, putting in the required information for your particular email account.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

petike779
Posts: 15
Joined: Sat Nov 09, 2019 5:24 pm

Re: Mail on Buster

Sun May 03, 2020 8:14 am

pcmanbob wrote:
Sat May 02, 2020 12:10 pm
You did nothing wrong , you have to create these 2 files using a simple file editor like nano, putting in the required information for your particular email account.
Thank you.....
After changing write permission and creating the 2 files working nice. Tested with:

Code: Select all

echo 'your message' | msmtp destination-email-address@gmail.com
Mail is sent successfully
Thank you for your advice
Peter

Chenko
Posts: 28
Joined: Wed Jul 03, 2019 1:56 am

Re: Mail on Buster

Tue May 26, 2020 9:05 am

paulv wrote:
Wed Jul 10, 2019 1:03 pm
Just to follow-up on the previous posts, ssmtp is deprecated on Buster, it is no longer maintained.
(typical experience with a major system change..., sigh!)

The more modern and supported alternative is msmtp.

You can install that package with:

Code: Select all

sudo apt-get install msmtp msmtp-mta
The configuration file is located here : /etc/msmtprc
Strangely enough, it is empty with no clues, which is different from the good old ssmtp.conf file.
However, there is a very large description with details if you use

Code: Select all

man msmtp
For gmail accounts, these are the specific elements you should put into /etc/msmtprc:

Code: Select all

# Generics
defaults
auth           on
tls            on
# following is different from ssmtp:
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# user specific log location, otherwise use /var/log/msmtp.log, however, 
# this will create an access violation if you are user pi, and have not changes the access rights
logfile        ~/.msmtp.log

# Gmail specifics
account        gmail
host           smtp.gmail.com
port           587

from          root@raspi-buster
user           your-gmail-accountname@gmail.com
password       your-gmail-account-password

# Default
account default : gmail
You can test this with:

Code: Select all

echo 'your message' | msmtp destination-email-address@gmail.com
I have not yet found a way to set the subject, there is no -s flag either.

However, if you also install mailutils:

Code: Select all

sudo apt-get install mailutils
Then these two work again:

Code: Select all

echo 'message' | mail -s "raspi-buster" destination-email-address@gmail.com
echo 'message' | sendmail destination-email-address@gmail.com
Unfortunately, my watchdog setup nor cron get the mail out. From the error message in /var/log/mail.err it seems that there is an incompatibility with this setup, and the previously established mail setup.

Hopefully somebody that is more adept can help out to get this fixed.


Hope this helps to get mail going on buster.

Enjoy!
hello i tried this but it did not work for me i dont know if its a mistake i made or how but i need help
i get this error wen i try to test it.

msmtp: authentication failed (method PLAIN)
msmtp: server message: 535-5.7.8 Username and Password not accepted. Learn more at
msmtp: server message: 535 5.7.8 https://support.google.com/mail/?p=BadCredentials h7sm503835wml.24 - gsmtp
msmtp: could not send mail (account default from /etc/msmtprc)

Return to “Troubleshooting”