Sendmail authentication error with gmail

30 visualizzazioni (ultimi 30 giorni)
Erin
Erin il 8 Lug 2015
Commentato: Tom il 1 Giu 2022
Here is my code:
myaddress = 'example@gmail.com';
mypassword = 'example';
setpref('Internet','E_mail',myaddress);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',myaddress);
setpref('Internet','SMTP_Password',mypassword);
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.socketFactory.class', ...
'javax.net.ssl.SSLSocketFactory');
props.setProperty('mail.smtp.socketFactory.port','465');
sendmail(toexample@cornell.edu,'email subject test',...
'this email is a test','D:\testimagetosend.tif')
And here is the error message: Error using sendmail (line 171) Authentication failed.
From everything else I have read, the preferences and properties required for gmail are all taken care of, but still getting the error.
  5 Commenti
Manikandan Prabakaran
Manikandan Prabakaran il 13 Set 2018
Mr.Bruno's solution works fine. Thanks a lot sir.

Accedi per commentare.

Risposte (2)

Walter Roberson
Walter Roberson il 8 Ago 2015
Within the last 8 months, Google turned off default support for an older less-secure authentication. You can re-enable it on your account... for now.
  4 Commenti
Shae Morgan
Shae Morgan il 8 Ott 2020
I'd like to add that if your use seems suspicious to google, it'll still fail the authentication attempt as suspicious activity.
Not sure how to work around this.
Tom
Tom il 1 Giu 2022
As of March 2022 Google has disabled this completely :/

Accedi per commentare.


Pankaj
Pankaj il 14 Apr 2016
Modificato: Pankaj il 14 Apr 2016
For some service providers the extension ' @gmail.com' in myaddress may cause authentication error. Simply use userID.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by