base error problem in sending email for matlab

UserName = 'myemail.ef230@gmail.com';
passWord = 'my password';
setpref('Internet','E_mail',UserName);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',UserName);
setpref('Internet','SMTP_Password',passWord);
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');
emailto = 'emailWhereToSend'; % recipient's email
sendmail(emailto, 'My Subject', 'My message');
when I run the code I get my sending email is not a valid base code

댓글 수: 6

I put my actual email and password in above. Is there anythign else that I need to put my actual information into?
and my error says "gmail.com is not a valid base class"
Adam Danz
Adam Danz 2019년 10월 8일
편집: Adam Danz 2019년 10월 8일
Please provide the full, copy-pasted error message and show the line that is throwing the error.
Note that virus software and firewalls are common problems as discussed here:
Error using sendmail (line 175)
Authentication failed.
Error in emailll (line 13)
sendmail(emailto, 'My Subject', 'My message');
Now I'm just not autherized. Any ideas how to fix it? It's the correct username and password.
I've also turned on access for unsecured apps.
Here are some things to try:
  • First I would triple-check that the access to unsecured apps is indeed turned off.
  • Then triple check that there are no typos in your email adderess and password (case sensitive!)
  • Confirm that your antivirus program isn't interfering by disabling your antivirus program temporarily and try to send the email again.
  • If that didn't work, do the same process for any firewall programs you might be using.
  • One forum member suggested that for some service providers the extension "@gmail.com" in the UserName variable may cause authentication error [1].
  • You could try using a proxy server [2]
Please follow-up to let us know what worked and didn't work.

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

답변 (1개)

Stephan
Stephan 2019년 10월 8일
편집: Stephan 2019년 10월 8일
content = 'This function works for me on gmail - try it...'
e_mail(content)
function e_mail(Content)
recipient = {'emailWhereToSend1','emailWhereToSend2'};
Subject = 'My Subject';
UserName = 'myemail.ef230@gmail.com';
Password = 'my password';
Server = 'smtp.gmail.com';
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.port', '587');
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.starttls.enable','true');
setpref('Internet','E_mail', UserName);
setpref('Internet','SMTP_Server', Server);
setpref('Internet','SMTP_Username', UserName);
setpref('Internet','SMTP_Password', Password);
sendmail(recipient, Subject, Content);
end

태그

질문:

2019년 10월 8일

댓글:

2019년 10월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by