Error using sendmail - Could not connect to SMTP host:, port: 25;

33 views (last 30 days)
I"m trying to send Email from my Matlab to my Email account. I used the following code:
props = java.lang.System.getProperties; props.setProperty('mail.smtp.auth','true'); setpref('Internet','SMTP_Server',''); setpref('Internet','SMTP_Username',''); setpref('Internet','SMTP_Password','myGmailPasword'); subject='first mail from my Matlab'; sendmail('',subject)
But received the following error message:
"Error using sendmail (line 171) Could not connect to SMTP host:, port: 25;"
I would be grateful to anyone willing to help. Eitam Luz

Answers (1)

fbaillon on 4 Aug 2017
You must enable StartTLS and spécifie the port :
props.setProperty( 'mail.smtp.starttls.enable', 'true' );
props.setProperty( 'mail.smtp.socketFactory.port', '587' );
This answer is a bit late, but if it can still help you...
Fabien Baillon

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!