Using sendmail with gmail oauth2 credentials

121 views (last 30 days)
Petorr on 8 Jun 2022
Commented: Petorr on 8 Jun 2022
I want to send emails programmatically from matlab through gmail, using sendmail. Gmail recently ended support for simple user&password SMTP and they now require oauth2. I almost have oauth2 working, but I think I am stuck on setting up sendmail to properly use "XOAUTH2" credentials. Sendmail returns an error, "Authentication failed."
My question is: assuming I have a valid access token with permissions "scope" set to, how do I configure the settings to use sendmail with XOAUTH2?
Any help appreciated, thanks!
Petorr on 8 Jun 2022
sendmail error:
Authentication failed.
% more detailed:
% 'Java exception occurred:
% javax.mail.AuthenticationFailedException
% at javax.mail.Service.connect(
% at javax.mail.Service.connect(
% at javax.mail.Service.connect(
% at javax.mail.Transport.send0(
% at javax.mail.Transport.send(
% '

Sign in to comment.

Accepted Answer

Jan on 8 Jun 2022
  1 Comment
Petorr on 8 Jun 2022
Yes, I saw that answer and it seems to work so far. I just don't know how long google will support this almost-the-same workaround, if the password expires occasionally or not, etc etc so I was hoping to get the whole oauth2 thing working. The method in the above answer does let me send emails as before, with gmail credentials and sendmail. Thanks Jan!

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!