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?
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.
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
I've been trying for a while to send an email and this has gotten me the furthest! Seem to be authenticating fine, but I'm still getting an error when it attempts to send the message:
Error using sendmail (line 171); Exception reading response; Unrecognized SSL message, plaintext connection?
I'm trying to use my university's smtp host which is starttls through port 587.
Image Analyst
el 5 de Nov. de 2015
Editada: Image Analyst
el 5 de Nov. de 2015
Well, for what it's worth, you can try my demo, attached.
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
0 votos
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.
Categorías
Más información sobre Web Services en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!