Guest User

Untitled

a guest
May 12th, 2018
714
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 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, .pdf etc.) locations
  5. senderEmail = 'rishikesh0014051992@gmail.com'
  6. senderPassword = 'myPassword@123'
  7. recipientEmails = {'rishikesh0011115067@gmail.com', 'tamzam@gmail.com'}
  8. headerMessage = 'SEND MAIL(GMAIL) USING MATLAB'
  9. bodyMessage = ['Hello sir, please check the updated PDF attached here.' ...
  10. 10 'It is best viewable in Chrome if you want to open it using browser.' ...
  11. 10 'Hacker.jpg & SEN-EMAIL(GMAIL)-USING-MATLAB.pdf are attached here.' ...
  12. 10 ' ' ...
  13. 10 'Best regards,' ...
  14. 10 'Rishikesh Agrawani']
  15. attachedFiles = {'H:\RishikeshAgrawani\images\programs\Hacker.jpg', ...
  16. 'H:\RishikeshAgrawani\Projects\Docs\MarkdownPdfs\SEND-EMAIL(GMAIL)-USING-MATLAB-UPDATED-03-MAY-2018-THU.pdf'}
  17.  
  18. % Specify encoding for email
  19. encoding = 'UTF-8'
  20.  
  21. % Specify SMTP server (It is fixed for Google mail)
  22. emailServer = 'smtp.gmail.com'
  23.  
  24. % By default, the `sendmail` function does not support email servers that require authentication.
  25. % To support these servers, change your system settings and set preferences for the
  26. % SMTP user name and password, with commands in the following form:
  27. props = java.lang.System.getProperties;
  28. props.setProperty('mail.smtp.auth','true');
  29. props.setProperty('mail.smtp.port', '587');
  30. props.setProperty('mail.smtp.starttls.enable','true');
  31.  
  32. setpref('Internet','SMTP_Server', emailServer);
  33. setpref('Internet','SMTP_Username', senderEmail);
  34. setpref('Internet','SMTP_Password', senderPassword);
  35. setpref('Internet','E_mail_Charset', encoding);
  36. setpref('Internet','E_mail', senderEmail)
  37.  
  38. disp('Sending mail with Header, Body, 1 jpg image, 1 pdf');
  39. sendmail(recipientEmails, headerMessage, bodyMessage, attachedFiles);
  40. ```
Add Comment
Please, Sign In to add comment