Guest User

Untitled

a guest
May 12th, 2018
842
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. ```matlab
  2. % Setting gmail credentials
  3. % Please use your own gmail(Google mail) credentials
  4. % And write your messages
  5. senderEmail = 'rishikesh0014051992@gmail.com'
  6. senderPassword = 'myPassword@123'
  7. recipientEmails = {'rishikesh0011115067@gmail.com', 'tamzam@gmail.com'}
  8. headerMessage = 'Hello World in MATLAB'
  9. bodyMessage = 'disp() is used to write message on console.'
  10.  
  11. % Specify encoding for email
  12. encoding = 'UTF-8'
  13.  
  14. % Specify SMTP server (It is fixed for Google mail)
  15. emailServer = 'smtp.gmail.com'
  16.  
  17. % By default, the `sendmail` function does not support email servers that require authentication.
  18. % To support these servers, change your system settings and set preferences for the
  19. % SMTP user name and password, with commands in the following form:
  20. props = java.lang.System.getProperties;
  21. props.setProperty('mail.smtp.auth','true');
  22. props.setProperty('mail.smtp.port', '587');
  23. props.setProperty('mail.smtp.starttls.enable','true');
  24.  
  25. setpref('Internet','SMTP_Server', emailServer);
  26. setpref('Internet','SMTP_Username', senderEmail);
  27. setpref('Internet','SMTP_Password', senderPassword);
  28. setpref('Internet','E_mail_Charset', encoding);
  29. setpref('Internet','E_mail', senderEmail)
  30.  
  31. sendmail(recipientEmails, headerMessage, bodyMessage);
  32. ```
Add Comment
Please, Sign In to add comment