Tyler Nappy

Tyler Nappy

MATLAB is a very powerful engineering tool for simulations and computations.  For those who use it – and use it extensively – you know the power that it can offer and basically how awesome it is.

So, how do you send email through MATLAB?  Here is a code snippet utilizing their built in ‘sendmail’ function:

For the above code to work properly, first thing’s first — sign up for a Mailjet account here to access Mailjet’s SMTP server.  After signing up and verifying yourself, head over to your SMTP settings.  Here, you will find your username (api key) and your password (secret key) which you input into ‘my_username’ and ‘my_password’, respectively.  Lastly, change ‘my_default_email_address’ to the email address tied to your existing Mailjet account (if you just signed up, use the one you signed up with).
And that’s that!  Customize the email recipient, the subject line, and the body of the email in the ‘sendmail’ function.

P.S. If you wish to use something other than Mailjet, you can use any SMTP service – Gmail, Hotmail, Yahoo, etc.  Just fill in the aforementioned settings with the appropriate values from the SMTP service you wish to use.