Receiving an error whilst attempting to use 'sendmail'
이전 댓글 표시
I'm trying to use Matlab to send emails using the sendmail command. My code (taken from various other locations) is
my_default_email_address = 'email@gmail.com'; %real email removed
my_password = '******'; %real password removed
setpref('Internet','E_mail',my_default_email_address);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',my_default_email_address);
setpref('Internet','SMTP_Password',my_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');
sendmail('recipient@live.co.uk','Test','Hello'); %real recipient removed
When I run this on R2015a I get the error:
Error using sendmail (line 171)
Exception reading response;
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid
certification path to requested target
whereas in R2013b I get:
Error using sendmail (line 172)
Could not connect to SMTP host: smtp.gmail.com, port: 25;
Connection timed out: connect
I've tried changing the port from 465 to 25 and I have also allowed 'less secure apps' to access my gmail account (using the link https://support.google.com/accounts/answer/6010255?hl=en).
Please can anyone help show me what I'm doing wrong. Thanks
댓글 수: 2
Image Analyst
2015년 12월 3일
Is this from your home network? Or through your company or university firewall? It's possible that the firewall does not allow outgoing emails except through known protocols and programs, like in my company.
Joel Bradshaw
2015년 12월 3일
편집: Joel Bradshaw
2015년 12월 3일
답변 (2개)
prince tiwari
2016년 3월 26일
0 개 추천
Error using sendmail (line 171) Could not connect to SMTP host: smtp.gmail.com, port: 25; Connection timed out: connect please solve my problem
카테고리
도움말 센터 및 File Exchange에서 Web Services에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!