フィルターのクリア

Exception reading response; Unrecognized SSL message, plaintext connection?

14 ビュー (過去 30 日間)
Padmanabham
Padmanabham 2014 年 12 月 14 日
コメント済み: Mohanad Bahshwan 2020 年 7 月 31 日
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?

回答 (1 件)

SuperNano
SuperNano 2015 年 11 月 5 日
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 件のコメント
Richard Fiola
Richard Fiola 2018 年 5 月 15 日
Thank-you SuperNano! This solved the problem for me as well.
Mohanad Bahshwan
Mohanad Bahshwan 2020 年 7 月 31 日
You are a hero SuperNano! Fixed my problem!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by