Sendmail authentication error with gmail
17 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
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
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Web Services 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!