I need to send email alert from my MATLAB program. I used below code to do that. But it is giving an error. How can I fix it?
function recipient = matlabmail(recipient, message, subject, sender, psswd)
if nargin<4
sender = 'mysender@gmail.com';
psswd = 'password';
end
setpref('Internet','E_mail',sender);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',sender);
setpref('Internet','SMTP_Password',psswd);
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');
sendmail('receive@gmail.com', 'Send Mail from Matlab', 'Hi from MATLAB');
This is the error massage I got:
email Error using sendmail (line 171) 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
Error in email (line 42) sendmail('receive@gmail.com', 'Send Mail from Matlab', 'Hi from MATLAB');