MatLab email feature

In case you want to have MatLab sending you an email to notify you about a simulation that ended or crashed you can use the following:

% Set up preferences. I think this is only needed once
setpref('Internet','E_mail',mail);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username','email_address@gmail.com');
setpref('Internet','SMTP_Password','your_password');
% System properties should be set up
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');

% Actually sending the email...
% The command is sendmail(address,subject,message,attachments);
% Yes, there can be attachements!
sendmail('bempelise@gmail.com',
	 'Test from MATLAB','Hello! This is a test from MATLAB!')

 

This little script will send an email to the address you specified. I only tried it with Gmail but I guess it should work just fine with any other mail.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s