Sendmail authentication error with gmail

조회 수: 29 (최근 30일)
Erin
Erin 2015년 7월 8일
댓글: Tom 2022년 6월 1일
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
Manikandan Prabakaran
Manikandan Prabakaran 2018년 9월 13일
Mr.Bruno's solution works fine. Thanks a lot sir.
machhindra bhamare
machhindra bhamare 2019년 2월 26일
thanks

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2015년 8월 8일
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
Shae Morgan
Shae Morgan 2020년 10월 8일
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 2022년 6월 1일
As of March 2022 Google has disabled this completely :/

댓글을 달려면 로그인하십시오.


Pankaj
Pankaj 2016년 4월 14일
편집: Pankaj 2016년 4월 14일
For some service providers the extension ' @gmail.com' in myaddress may cause authentication error. Simply use userID.

카테고리

Help CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by