How do I use SENDMAIL to send email from a SMTP server that uses authorization in MATLAB 7.10 (R2010a)?

47 views (last 30 days)
I would like to send an email using a server that requires authorization. However, this server does not support SSL. How can I do this?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 30 Sep 2013
To send an email from a non-SSL SMTP server that requires authorization, please use the code below.
Make sure to substitute your actual email address, password, and SMTP server information in the first three lines of code. Contact your local technical support department to determine the address of your SMTP server.
mail = 'myemail@address.com; % Replace with your email address
password = 'l1ll1put'; % Replace with your email password
server = 'smtp.server.net'; % Replace with your SMTP server
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.port','587');
% Apply prefs and props
setpref('Internet','E_mail',mail);
setpref('Internet','SMTP_Server',server);
setpref('Internet','SMTP_Username',mail);
setpref('Internet','SMTP_Password',password);
% Send the email
sendmail('receiver@email.com', 'Test', 'Msg from MATLAB');
Note that the above commands are undocumented and may change in future MATLAB releases, but they were last verified in MATLAB 8.2 (R2013b). 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.
  1 Comment
Mohammed Alabiech
Mohammed Alabiech on 8 Feb 2017
I have some problem when execute this code the error message is // Error using sendmail (line 171) Could not connect to SMTP host: smtp.mail.yahoo.com, port: 465, response: -1

Sign in to comment.

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2013b

Community Treasure Hunt

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

Start Hunting!