Whenever I use the sendmail function, I get an error that reads "Error using sendmail (line 171) Authentication failed." I am pretty sure the preferences and settings are properly set up. Does anyone know how to resolve this issue?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Whenever I use the sendmail function, I get an error that reads "Error using sendmail (line 171) Authentication failed." I am pretty sure the preferences and settings are properly set up. Does anyone know how to resolve this issue? I changed the settings on gmail as well for less security.
0 comentarios
Respuestas (3)
Manoj Das
el 20 de Jun. de 2015
Editada: Walter Roberson
el 20 de Jun. de 2015
Hello Joseph,
Here is what you do to make your sendmail command to work.. follow the below code
mail = 'my_yahoo_id@yahoo.com';
psswd = 'my_password';
host = 'smtp.mail.yahoo.com';
port = '465';
emailto = 'recepient_id@gmail.com';
m_subject = 'subject';
m_text = 'test';
setpref( 'Internet','E_mail', mail );
setpref( 'Internet', 'SMTP_Server', host );
setpref( 'Internet', 'SMTP_Username', mail );
setpref( 'Internet', 'SMTP_Password', psswd );
props = java.lang.System.getProperties;
props.setProperty( 'mail.smtp.user', mail );
props.setProperty( 'mail.smtp.host', host );
props.setProperty( 'mail.smtp.port', port );
props.setProperty( 'mail.smtp.starttls.enable', 'true' );
props.setProperty( 'mail.smtp.debug', 'true' );
props.setProperty( 'mail.smtp.auth', 'true' );
props.setProperty( 'mail.smtp.socketFactory.port', port );
props.setProperty( 'mail.smtp.socketFactory.class', 'javax.net.ssl.SSLSocketFactory' );
props.setProperty( 'mail.smtp.socketFactory.fallback', 'false' );
sendmail( emailto , 'Hello from MATLAB', 'Hello from MATLAB' );
when you open matlab you can have all these lines included in the startup script so you just have to use the sendmail command directly. Also as shown above yo ucan replace the smtp server settings accordingly for gmail by changing the smtp mail server address. The above works for MATLAB versions. In recent times I am lead to believe gmail has changed some settings since the above does not work for gmail anymore .. you still get an authentication failed error.. Hope this helps
4 comentarios
SuperNano
el 5 de Nov. de 2015
Thanks Image Analyst, but I found a simpler solution. Since starttls is actually a plain text protocol, if the server is using it (like the case of my uni server) there is no need to use the SSL socketFactory class. So either comment out that line or if you had already ran it (like me), use props.remove( 'mail.smtp.socketFactory.class' );
This is probably useless for most, but just in case!
Andreas
el 31 de Mzo. de 2016
@Juan not useless for me! Thanks to the above lines by Manoj and your hint of removing the SSL socketFactory class, I finally made sendmail work with the TUM / LRZ postout server. Thanks a lot!
Image Analyst
el 11 de Mzo. de 2015
Try it on a different account. If that doesn't work, try it on a different computer. I have one computer, my official work computer, where I can't sent email because of some security/firewall restrictions, but on a different computer it works fine.
0 comentarios
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!