Effacer les filtres
Effacer les filtres

Exception reading response; Unrecognized SSL message, plaintext connection?

14 vues (au cours des 30 derniers jours)
Padmanabham
Padmanabham le 14 Déc 2014
Commenté : Mohanad Bahshwan le 31 Juil 2020
mail = 'email@company.com';
password = 'pwd@123';
setpref('Internet','SMTP_Server','email.company.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.socketFactory.class',javax.net.ssl.SSLSocketFactory');
props.setProperty('mail.smtp.socketFactory.port','587');
sendmail('yyy@company.com','Test from MATLAB','Hello! This is a test from MATLAB!')
sendmail('yyy222@gmail.com','Test from MATLAB','Hello! This is a test from MATLAB!')
After Executing the above program ,there is an exception caught:
??? Error using ==> sendmail at 168 Exception reading response; Unrecognized SSL message, plaintext connection?
Please Suggest what changes i need to do for sending email through SSL?

Réponses (1)

SuperNano
SuperNano le 5 Nov 2015
Might be a bit of a late answer for you, but I just got through resolving a similar issue. If your company's smtp server is using port 587, it probably means it's using starttls, which is a plain text protocol with an upgrade to TLS. So if we tell matlab to use SSL, it doesn't understand the plain text responses. So need to omit the line props.setProperty('mail.smtp.socketFactory.class','javax.net.ssl.SSLSocketFactory'); or if you've already set it, use props.remove('mail.smtp.socketFactory.class'); to delete the key. Additionally you probably need to enable starttls with props.setProperty('mail.smtp.starttls.enable', 'true' );
This worked for me!
  2 commentaires
Richard Fiola
Richard Fiola le 15 Mai 2018
Thank-you SuperNano! This solved the problem for me as well.
Mohanad Bahshwan
Mohanad Bahshwan le 31 Juil 2020
You are a hero SuperNano! Fixed my problem!

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by