I am using msmtp to sent emails but getting authentication error although my login credentials were right.
my msmtprc file contains
defaults
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account default
host smtp.gmail.com
port 25
auth on
user *******@gmail.com
password *********
from **********@gmail.com
logfile /var/log/msmtp.log
on running this command on terminal
echo -e "Subject: Test Mail\r\n\r\nThis is my first test email." |msmtp --debug --from=default -t [email protected]
I get the following errors
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 b14sm68898705pfi.92 - gsmtp msmtp: could not send mail (account default from /etc/msmtprc)
I just had the same issue. I have a Debian 10 32bit with PHP 7.3.14-1, and the /etc/msmtprc file has...
account <myusername>@gmail.com
host smtp.gmail.com
port 587
tls on
tls_starttls on
auth on
user <myusername>
password <plain-password>
from <username>@gmail.com
account default : <username>@gmail.com
This configuration sends the email with no errors using smtp.gmail.com, then I have a GCE (Google Compute Engine) with Debian 10 64bit and PHP 7.3.14-1, with the exact same configuration file and it does not work. I enabled the 2-step verification method and generated a 16 character password for my script, with the App Password, the GCE just worked. Of course the 32bit machine is not able to send emails anymore, but my priority was the GCE machine. The configuration file on GCE is...
# Set default values for all following accounts.
defaults
port 587
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account gmail
host smtp.gmail.com
from <myusername>@gmail.com
auth on
user <myusername>@gmail.com
password <16 character password from Gmail>
# Set a default account
account default : gmail
It's probably worth mention that the 32bit machine has gCloud SDK and it's fully capable of login and connect to the GCE instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With