How to send an email using MATLAB? How to check internet connection in MATLAB?

Video explains how to send email through MATLAB. In this video it explains to configure the MALTAB with the gmail/ google SMTP server. This video also shows how to test the internet connection from within MATLAB.

We will be glad to hear from you regarding any query, suggestions or appreciations at:

Source code:

% SendEmail

setpref(‘Internet’,’E_mail’,’’); % Need to give the email ID

props = java.lang.System.getProperties;

setpref(‘Internet’,’SMTP_Username’,’’); % Need to give the email ID
setpref(‘Internet’,’SMTP_Password’,’**********’); % Need to give the password

sendmail(‘’, ‘MATLAB Test’, ‘Test Email’)


  1. hey there, i got an error stating:

    Unrecognized function or variable ‘getproperties’.

    Error in myEmail (line 6)
    props = java.lang.System.getproperties;

    what should i do to get the above statement work?

    • Try with the below line:
      props = java.lang.System.getProperties;

      ‘P’ capital in getProperties. Commands in Matlab are case sensitive.

      Programmer World

Leave a Reply