Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```matlab
- % Setting gmail credentials
- % Please use your own gmail(Google mail) credentials
- % And write your messages, specify your file(.png, .jpg, .txt etc.) locations
- senderEmail = 'rishikesh0014051992@gmail.com'
- senderPassword = 'myPassword@123'
- recipientEmails = {'rishikesh0011115067@gmail.com', 'tamzam@gmail.com'}
- headerMessage = 'Hello World in MATLAB'
- bodyMessage = 'disp() is used to write message on console. Hacker.jpg is attached here.'
- attachedFiles = {'H:\RishikeshAgrawani\images\programs\Hacker.jpg'}
- % Specify encoding for email
- encoding = 'UTF-8'
- % Specify SMTP server (It is fixed for Google mail)
- emailServer = 'smtp.gmail.com'
- % By default, the `sendmail` function does not support email servers that require authentication.
- % To support these servers, change your system settings and set preferences for the
- % SMTP user name and password, with commands in the following form:
- props = java.lang.System.getProperties;
- props.setProperty('mail.smtp.auth','true');
- props.setProperty('mail.smtp.port', '587');
- props.setProperty('mail.smtp.starttls.enable','true');
- setpref('Internet','SMTP_Server', emailServer);
- setpref('Internet','SMTP_Username', senderEmail);
- setpref('Internet','SMTP_Password', senderPassword);
- setpref('Internet','E_mail_Charset', encoding);
- setpref('Internet','E_mail', senderEmail)
- sendmail(recipientEmails, headerMessage, bodyMessage, attachedFiles);
- ```
Add Comment
Please, Sign In to add comment