updated as but the error persists...
sending E-mail error
4 ビュー (過去 30 日間)
古いコメントを表示
Türk:
Merhaba;
MATLAB ile e-posta göndermek istiyorum ama bu kodları buldum (Sendmail kullanarak hata (satır 172)
İstisna okuma cevabı;
sun.security.validator.ValidatorException: PKIX yolu oluşturulamadı: sun.security.provider.certpath.SunCertPathBuilderException: geçerli bulunamıyor
istenen hedefe yönelik sertifika yolu
Bu hatayla karşılaştığım sorun nedir?
Teşekkürler...
English:
Hi;
I want to send e-mail with MATLAB but I found these codes (Error using sendmail (line 172)
Exception reading response;
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid
certification path to requested target )
What's the problem I'm having with this error?
Thanks...
%
% parameters
mail = 'mymail@gmail.com'; % my gmail address
password = 'mypassword'; % my gmail password
host = 'smtp.mail.com';
% preferences
setpref('Internet','SMTP_Server', host);
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','465');
% Send the email
sendmail(mail,'Test from MATLAB','Hello! This is a test from MATLAB!')
2 件のコメント
mark filan
2019 年 7 月 31 日
Enabling access for "less secure apps" means that the client/app doesn't use OAuth 2.0 . OAuth 2.0 is the industry-standard protocol for authorization. When you sign in with OAuth 2.0, you sign in to Google's system directly. In OAuth 2.0 , you authenticate directly to Gmail with your credentials and authorize an app to do certain things. The third-party app only sees an authorization token provided by Google as proof that you authenticated correctly and agreed to authorize that app.
採用された回答
Adam Danz
2018 年 11 月 30 日
編集済み: Adam Danz
2019 年 5 月 4 日
Here's a quick example of a demo that produces an email sent from a gmail account (specifically). Note that to send an email through your gmail account you have to turn off the app security which greatly reduces the security of your gmail account. One solution to this problem is creating a new gmail account for the sole purpose of sending emails from this script.
To turn off app security, sign into gmail and access this link: https://myaccount.google.com/lesssecureapps
[Update] See comments below regarding common problems with antivirus software and firewalls that might prevent the email from being sent.
% User input
source = 'myFakeEmail@gmail.com'; %from address (gmail)
destination = 'kofte@foobar.com'; %to address (any mail service)
myEmailPassword = 'sifre123'; %the password to the 'from' account
subj = 'This is the subject line of the email'; % subject line
msg = 'This is the main body of the email.'; % main body of email.
%set up SMTP service for Gmail
setpref('Internet','E_mail',source);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',source);
setpref('Internet','SMTP_Password',myEmailPassword);
% Gmail server.
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','465');
% Send the email
sendmail(destination,subj,msg);
% [Optional] Remove the preferences (for privacy reasons)
setpref('Internet','E_mail','');
setpref('Internet','SMTP_Server','''');
setpref('Internet','SMTP_Username','');
setpref('Internet','SMTP_Password','');
11 件のコメント
Ahmed bin Ali
2023 年 6 月 20 日
How to use this on ThingSpeak? When ran the code this message shows up:
"send alert: This functionality is not available on remote platforms."
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Web Services についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!