일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- vector angle
- Vibration
- Rigid body
- C
- FEBiO
- send email
- Heat transfer analysis
- plot vector
- FEA
- 영어표현
- Steady state heat transfer
- transform
- 컨택해석
- MATLAB
- Biphasic
- finite element analysis
- FEBio tutorial
- abaqus
- 접촉해석
- 이메일영어
- 이메일 영어
- Multi-step loading
- Tensile test
- plot3
- contact
- 아바쿠스
- Today
- Total
Enjoy Learning & Knowing
Sending an email in Matlab 본문
I have figured out “sending an email in matlab” from https://www.mathworks.com/help/matlab/import_export/sending-email.html
https://www.mathworks.com/help/matlab/ref/sendmail.html
and some web searching.
% setting up an email address and SMTP server information with ‘setpref’ Matlab function.
mail = ‘xxxxx@gmail.com'; % gmail address
password = 'xxxxxxxx'; % gamail password
% outgoing SMTP server address
% setpref('Internet','SMTP_Server','mail.server.network');
setpref('Internet','SMTP_Server','smtp.gmail.com');
% setting up my email address and password
% setpref('Internet','E_mail','youraddress@yourserver.com');
setpref('Internet','E_mail',mail);
setpref('Internet','SMTP_Username',mail);
setpref('Internet','SMTP_Password',password);
% using ‘sendmail’ command
% Because ‘sendmail’ does not support HTML format messages, we can send HTML
% message using attachment option
% According to Matlab manual, ‘sendmail’ function does not support email servers that require
% authentication.
% User need to change system setting and set preferences for the SMTP user name and password
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.socketFactory.class','javax.net.ssl.SSLSocketFactory');
props.setProperty('mail.smtp.socketFactory.port','465');
% I am not sure what the above line means but maybe find some information from
% https://support.google.com/a/answer/176600?hl=en
% recipient email address
sendmail('xxxxxxxx@hotmail.com','Hello From MATLAB!');
When I ran this code, I’ve got the following error message.
Through web searching, I found a kind guy explained why there is an authentication error when using ‘sendmail’.
(https://www.mathworks.com/matlabcentral/answers/409343-sending-emails-through-matlab)
Need an additional setup in my gmail account to resolve the authentication error. Please see the following website for further information.
https://support.google.com/a/answer/6260879?hl=en
We need to turn on to allow less secure apps at the following address https://myaccount.google.com/lesssecureapps
I could check the authentication error in my gmail account. When I tried to send an email without allowing less secure apps, I’ve got the following message from google.
Finally, everything works fine after turning on the less secure apps, and I can check the email.
There are some options in Matlab such as using multiple recipients and attaching files. But I may not use Matlab often to send emails.
'Matlab' 카테고리의 다른 글
Matlab: Fit linear regression model (0) | 2019.03.29 |
---|