Receiving an error whilst attempting to use 'sendmail'
Mostrar comentarios más antiguos
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 comentarios
Image Analyst
el 3 de Dic. de 2015
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
el 3 de Dic. de 2015
Editada: Joel Bradshaw
el 3 de Dic. de 2015
Respuestas (2)
Joel Bradshaw
el 3 de Dic. de 2015
0 votos
prince tiwari
el 26 de Mzo. de 2016
0 votos
Error using sendmail (line 171) Could not connect to SMTP host: smtp.gmail.com, port: 25; Connection timed out: connect please solve my problem
Categorías
Más información sobre Web Services en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!