在matlab

时间:2016-10-08 01:19:55

标签: matlab email

我可以使用以下代码使用matlab发送电子邮件:

mail = 'myEmail@gmail.com>';
password = 'PASSWD';

% Set up the preferences
setpref('Internet','E_mail',mail);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',mail);
setpref('Internet','SMTP_Password',password);

% The following is necessary only if you are using GMail as
% your SMTP server. 
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');
% send email
sendmail('receipient@gmail.com', 'subject', 'messsage');

基本上我是使用myEmail@gmail.com发送电子邮件而我能够接收来自receipient@gmail.com的电子邮件。但是,当我收到电子邮件时,电子邮件正文的“发件人”字段为“myEmail”。这是我收到的原始电子邮件的正文:

Message ID  <1180952044.01475877272727.JavaMail.myUserName@myMachine>
Created at: Fri, Oct 7, 2016 at 5:54 PM (Delivered after 1 seconds)
From:   myEmail@gmail.comUsing MATLAB 9.0.0.341360 (R2016a)
To: receipient@gmail.com
Subject:    subject

我想知道我是否可以将“从字段”更改为某些用户定义的名称。我试着按照这里的说明进行操作:https://www.mathworks.com/matlabcentral/answers/63504-how-do-i-change-the-from-fieild-of-an-email-using-matlab-s-sendmail但是,我收到错误:

Error using sendmail (line 171)
Authentication failed.

这有什么解决方案吗?谢谢!

0 个答案:

没有答案