sending emails through Matlab
31 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lalitha Srilal Kannangara Arachchige
el 8 de Jul. de 2018
Comentada: Omar Salah
el 5 de Ag. de 2021
I have tried with following code.
mail = 'my_email@gmail.com';
password = 'my_password';
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','E_mail',mail);
setpref('Internet','SMTP_Username',mail);
setpref('Internet','SMTP_Password',password);
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.starttls.enable','true');
%props.setProperty('mail.smtp.socketFactory.class', 'javax.net.ssl.SSLSocketFactory');
%props.setProperty('mail.smtp.socketFactory.port','25');
sendmail(sent_email,'Test from MATLAB','Hello! This is a test from MATLAB!')
But it gives the following error after allowing access to the low-security application through Gmail account.
"Error using sendmail (line 175)
Could not connect to SMTP host: smtp.gmail.com, port: 25, response: 421"
can anyone help me to solve this issue?
0 comentarios
Respuestas (1)
Kojiro Saito
el 9 de Jul. de 2018
As this page says, smtp.gmail.com uses port 465 (SSL) or 587 (TLS), so you need to specify port number.
props.setProperty('mail.smtp.socketFactory.port','465');
Also, by default, Gmail blocks less secure apps, so you need to enable it following the steps in this page. If you have Google accounts on your own, a simple way is enabling less secure apps from https://myaccount.google.com/lesssecureapps.
1 comentario
Ver también
Categorías
Más información sobre Web Services en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!