Exception reading response; Unrecognized SSL message, plaintext connection?
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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?
0 Kommentare
Antworten (1)
SuperNano
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Web Services finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!