I have successfully setup a system config to send emails using msmtp. Below is the configuration (located in /etc/msmtprc).
account default
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile /var/log/msmtp
# gmail
host smtp.gmail.com
port 587
from <account>@gmail.com
user <account>
password <password>
# Syslog logging with facility LOG_MAIL instead of the default LOG_USER
syslog LOG_MAIL
I wanted to use libsecret to not have the password showing, so I did the following
secret-tool store --label=msmtp host smtp.gmail.com service smtp user <account>
I verified that the password was stored by typing:
secret-tool lookup host smtp.gmail.com
I then modified /etc/msmtprc as follows:
account default
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile /var/log/msmtp
# gmail
host smtp.gmail.com
port 587
from <account>@gmail.com
user <account>
# Syslog logging with facility LOG_MAIL instead of the default LOG_USER
syslog LOG_MAIL
This is not working.
If I dump /var/log/msmtp I get the following:
Nov 12 14:36:30 host=smtp.gmail.com tls=on auth=on user= [email protected] recipients= smtpstatus=535 smtpmsg='535-5.7.8 Username and Password not accepted. Learn more at\n535 5.7.8 https://support.google.com/mail/?p=BadCredentials n10sm6743893wrv.77 - gsmtp' errormsg='authentication failed (method PLAIN)' exitcode=EX_NOPERM
What am I doing wrong?
Thanks
In the file /etc/msmtprc I replaced password with passwordeval, pointing this to the libsecret command to extract the password.