Guest User

Untitled

a guest
May 12th, 2018
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. ```matlab
  2. % Setting gmail credentials
  3. % Please use your own gmail(Google mail) credentials
  4. % And write your messages, specify your file(.png, .jpg, .txt etc.) locations
  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. Hacker.jpg is attached here.'
  10. attachedFiles = {'H:\RishikeshAgrawani\images\programs\Hacker.jpg'}
  11.  
  12. % Specify encoding for email
  13. encoding = 'UTF-8'
  14.  
  15. % Specify SMTP server (It is fixed for Google mail)
  16. emailServer = 'smtp.gmail.com'
  17.  
  18. % By default, the `sendmail` function does not support email servers that require authentication.
  19. % To support these servers, change your system settings and set preferences for the
  20. % SMTP user name and password, with commands in the following form:
  21. props = java.lang.System.getProperties;
  22. props.setProperty('mail.smtp.auth','true');
  23. props.setProperty('mail.smtp.port', '587');
  24. props.setProperty('mail.smtp.starttls.enable','true');
  25.  
  26. setpref('Internet','SMTP_Server', emailServer);
  27. setpref('Internet','SMTP_Username', senderEmail);
  28. setpref('Internet','SMTP_Password', senderPassword);
  29. setpref('Internet','E_mail_Charset', encoding);
  30. setpref('Internet','E_mail', senderEmail)
  31.  
  32. sendmail(recipientEmails, headerMessage, bodyMessage, attachedFiles);
  33. ```
Add Comment
Please, Sign In to add comment