Sendmail 'Authentication failed' error at office365.com

Hi all:
I'm trying to configure sendmail to send me an email when something breaks. I am having a hard time getting it to work with Office365.com. I've been up and down the web and have found similar problems (with gmail, not office365) and have been learning a lot about java email settings, but have not been successful.
I have verified that I'm seeing the server, I get replies when I ping and see the server when I telnet over to smtp.office365.com. I set up the account on Thunderbird and it sends mail just fine. I've verified that 'authorized SMTP' is enabled at office365.com. Running out of ideas on what else to try or how else to debug.
Here is what I am using:
mail = 'name@domain.org';
password = 'xxx';
server = 'smtp.office365.com';
port = '587';
setpref('Internet','E_mail', mail);
setpref('Internet','SMTP_Server', server);
setpref('Internet','SMTP_Username', mail);
setpref('Internet','SMTP_Password', password);
props = java.lang.System.getProperties;
props.setProperty( 'mail.smtp.ssl.trust', server);
props.setProperty( 'mail.smtp.user', mail );
props.setProperty( 'mail.smtp.password', password );
props.setProperty( 'mail.smtp.host', server );
props.setProperty( 'mail.smtp.port', port );
props.setProperty( 'mail.smtp.starttls.enable', 'true' );
props.setProperty( 'mail.smtp.auth', 'true' );
sendmail('recipent@domain.org','Subject','Message')
It returns:
Error using sendmail (line 175)
Authentication failed.
Anyone have any ideas or thoughts on how to debug?
Thanks, Rob

3 Comments

Hi Rob,
I get the exact same results.
For information, I used to send mail with Matlab using smtp.office365.com when I first tried in december 2021 and January 2022. I used the same method as yours. The only difference is I didn't need the props.setProperty( 'mail.smtp.ssl.trust', server);
I tried again 2 weeks ago and get the Authentication failed error since.
Last, but not the least, I tried with a basic Python script and a powershell script and it worked fine.
The problem appears only with Matlab (2019b for me).
Did you get anys support from Matlab or anyone else ?
Regards,
Alexis DRON
I have exact the same problem in MATLAB 2022b.
I found the problem. SMTP AUTH hast to be disabled.
props.setProperty( 'mail.smtp.auth', 'false' );

Sign in to comment.

Answers (1)

When I am using this code I am getting an error :
Error using sendmail
530 5.7.57 Client not authenticated to send mail. [VI1PR0102CA0080.eurprd01.prod.exchangelabs.com
2023-10-03T15:12:54.961Z 08DBC367B59984EF]
Do you have any suggestion for this?

Products

Release

R2019a

Asked:

on 8 Feb 2022

Answered:

on 3 Oct 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!