Send Email using gmail failed

3 ビュー (過去 30 日間)
JAY CAMERON
JAY CAMERON 2020 年 6 月 3 日
回答済み: Jyotsna Talluri 2020 年 6 月 9 日
I used the example code from your site and I am sure it worked except the gmail rejected the use of my account with this message:
_____________________________________________
Someone just used your password to try to sign in to your account from a non-Google app. Google blocked them, but you should check what happened. Review your account activity to make sure no one else has access.
_______________________________________
___________________________
On the Matlab side the error was:
Error using sendmail (line 175)
Authentication failed.
___________________________________________
the program I used from an example is pasted below:
source = 'matlabemailwarning@gmail.com'; %from address (gmail)
destination = 'cameron_jay1941@yahoo.com'; %to address (any mail service)
myEmailPassword = 'zaqWSX12'; %the password to the 'from' account
subj = 'This is the subject line of the email'; % subject line
msg = 'This is the main body of the email.'; % main body of email.
%set up SMTP service for Gmail
setpref('Internet','E_mail',source);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',source);
setpref('Internet','SMTP_Password',myEmailPassword);
% Gmail server.
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');
% Send the email
sendmail(destination,subj,msg); %<<<<<<<<<<<<<<<<< error here

採用された回答

Jyotsna Talluri
Jyotsna Talluri 2020 年 6 月 9 日
You also have to set the preferences through GMAIL to allow interaction with MATLAB. You can do it with the following link:

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by