This change has been incorporated into the documentation in Release 2011a (R2011a). For previous releases, read below for any additional information:
To send email using SENDMAIL via the GMail/Yahoo server, you can execute the following in the MATLAB Prompt:
Gmail Server:
mail = 'sendemail.example.mathworks@gmail.com';
password = 'testing1234';
setpref('Internet','SMTP_Server','smtp.gmail.com');
Yahoo Server:
mail = 'sendemail.example_mathworks@yahoo.com';
password = 'testing1234';
setpref('Internet','SMTP_Server','smtp.mail.yahoo.com');
Gmail/Yahoo Servers:
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');
sendmail(mail,'Test from MATLAB','Hello! This is a test from MATLAB!')
In R2013a, the following command might also resolve the issue:
props.setProperty('mail.smtp.starttls.enable','true');
Note that the above commands are undocumented and may change in future MATLAB releases. Also, note that SENDMAIL does not support servers that require username and password authentications in MATLAB 7.1 (R14SP3) and before and hence the above commands will not work with those releases.
Best Answer