Thursday 27 February 2014

How to send emails from Matlab

Hey Everyone !

In this blog i'm going to teach you how to send emails from MATLAB.

Its very Easy..Just one command will do the trick for you..
sendmail('meetleopauly@yahoo.com', 'Gmail Test', 'This is a test message.');

The syntax is as follows :
sendmail('your address', 'title', 'your message.');

But you need to do a lil bit of preference changes before you use this command.

myaddress = 'mail address';    % give the address from which you need to send the mail from
mypassword = 'password';    % give your password

setpref('Internet','E_mail',myaddress);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',myaddress);
setpref('Internet','SMTP_Password',mypassword);

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');

Just copy the above code.Run it and use the send mail command.

Here what we have done is we have used one of the google's silent features the  portable SMTP server.You can read more about Google's SMTP server Here .

So friends try this out...Have fun :-)



No comments:

Post a Comment