Send Email using gmail failed

3 views (last 30 days)
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 = ''; %from address (gmail)
destination = ''; %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
% Gmail server.
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.socketFactory.class', '');
% Send the email
sendmail(destination,subj,msg); %<<<<<<<<<<<<<<<<< error here

Accepted Answer

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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!