PHP+Ubuntu Send email using office365

  email, office365, php, server, ubuntu

I faced this issue : I used msmtp for sending mail by my VPS with gmail with no problem, and know I try to do the same but with office365 but when I do echo -e "Subject: Test MailrnrnThis is my first test email." |msmtp --debug --from=default -t [email protected] I have this error message :

msmtp: authentication failed (method LOGIN)
msmtp: server message: 535 5.7.3 Authentication unsuccessful [A■4■R■7■1■A■042.eurprd07.prod.outlook.com]
msmtp: could not send mail (account default from /etc/msmtprc)

Here is my /etc/msmtprc :

  GNU nano 4.8                      /etc/msmtprc
defaults
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
tls_certcheck on

account default
host smtp.office365.com
port 587
auth on
user myoffice365mail
password myoffice365mailmdp
from myoffice365mail
logfile /var/log/msmtp.log

Do you have an idea on what cause the error ?
I followed many topic on internet, but I didn’t find any solution…
Thank you for your time.

Source: Ask PHP

LEAVE A COMMENT