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: programmerworld1990@gmail.com

Source code:

% SendEmail

setpref(‘Internet’,’SMTP_Server’,’smtp.gmail.com’);
setpref(‘Internet’,’E_mail’,’abcd@gmail.com’); % Need to give the email ID

props = java.lang.System.getProperties;
props.setProperty(‘mail.smtp.auth’,’true’);
props.setProperty(‘mail.smtp.starttls.enable’,’true’);

setpref(‘Internet’,’SMTP_Username’,’abcd@gmail.com’); % Need to give the email ID
setpref(‘Internet’,’SMTP_Password’,’**********’); % Need to give the password

sendmail(‘abcd@gmail.com’, ‘MATLAB Test’, ‘Test Email’)

5 comments

  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.

      Cheers
      Programmer World

Leave a Reply