Getting the error : Exception reading response; Unrecognized SSL message, plaintext connection?
236 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
UserName = 'email@gmail.com';
passWord = 'xxxxxx';
setpref('Internet','E_mail',UserName);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',UserName);
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');
emailto = 'email@xxx.com'; % recipient's email
sendmail(emailto, 'My Subject', 'My message');
Getting the error : Exception reading response;
Unrecognized SSL message, plaintext connection?
I know someone got the same problem (and it was almost the same topic), but I didn't find my solution on his topic ....
0 commentaires
Réponses (1)
Muskan
le 23 Sep 2024
Hi,
There generally two options of ports for outbound emails: 587 and 465.
Port 587 is the preferred mail submission port. It uses TLS encryption which needs STARTTLS to be enabled. Port 587 can be enabled with the following commands:
>> props = java.lang.System.getProperties;
>> props.setProperty('mail.smtp.starttls.enable','true');
>> props.setProperty('mail.smtp.port','587')
Port 465 was deprecated two years after its initiation, but it is still used to support legacy systems. Port 465 uses SSL encryption and can be enabled with the following commands:
>> props = java.lang.System.getProperties;
>> props.setProperty('mail.smtp.socketFactory.class','javax.net.ssl.SSLSocketFactory');
>> props.setProperty('mail.smtp.socketFactory.port','465');
When using Port 587 with TLS, make sure that 'mail.smtp.socketFactory.class' is not set to 'javax.net.ssl.SSLSocketFactory' which is the case here. The 'javax.net.ssl.SSLSocketFactory' can be unset by restarting MATLAB or by running either of the following functions:
>> props.setProperty('mail.smtp.socketFactory.class','');
>> props.remove('mail.smtp.socketFactory.class');
For additional debugging messages, add the following command:
>> props.setProperty('mail.debug','true');
Additionally, descriptions for the Java SMTP protocol package can be found in the following link: https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html
I hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Call Web Services from MATLAB Using HTTP dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!