1

I am configuring msmtprc smtp to send an outbound email and having a trouble with office365. It's working fine with Gmail account, but I am getting the following error with office 365.

msmtp: authentication failed (method LOGIN) msmtp: server message: 535 5.7.3 Authentication unsuccessful [BN6PR13CA0016.namprd13.prod.outlook.com] msmtp: could not send mail (account default from /etc/msmtprc)

/var/log/msmtp.log

Authentication unsuccessful [BN6PR13CA0016.namprd13.prod.outlook.com]' errormsg='authentication failed (method LOGIN)' exitcode=EX_NOPERM

/etc/msmtprc

defaults auth on logfile /var/log/msmtp.log account office host smtp.office365.com port 587 protocol smtp from support@example.net user support@example.net password ******* tls on tls_starttls on tls_trust_file /etc/pki/tls/certs/ca-bundle.crt

Does anyone successfully use Msmtprc with office365?

Thank you.

Mike
  • 297
  • 5
  • 17

1 Answers1

1

I've been successfully using msmtp fine for quite some time, using the following settings (on a CentOS 7 box), but with the config in $HOME/.msmtprc since it's just for my user rather than globally:

account          default
host             smtp.office365.com
port             587
tls              on
tls_starttls     on
tls_trust_file   /etc/ssl/certs/ca-bundle.crt
tls_certcheck    on
auth             on
user             username@example.com
passwordeval     pass office365.com
from             username@example.com
logfile          ~/.msmtp.d/msmtp.log

..so this is 99% the same as yours except that instead of having the password in the file I'm using passwordeval to provide it via the output of the given command.

Perhaps multiple spaces between password and the password itself is causing the spaces to be added to the start of the password?

You could also try running msmtp so that it has a controlling terminal (i.e. run from the shell rather than via the service manager as with systemctl) to test whether providing it the password that way works as expected?

David Gardner
  • 6,952
  • 4
  • 35
  • 37
  • Since posting this our O365 now requires OAUTH2, and I've been using `msmtp` pointed at `davmail` for sending mail as that's been the simplest way to support this (but it is very slow at sending sometimes). – David Gardner Mar 17 '22 at 12:31