问题描述
在使用MATLAB发送邮件时候出现:错误使用 sendmail (line 175)
503 Error: need EHLO and AUTH first !
问题源代码
function mailme(password,MailServer,MailAddress,recipients,subject,message,attachments)
setpref('Internet','E_mail',MailAddress);
setpref('Internet','SMTP_Server',MailServer);%SMTP服务器
setpref('Internet','SMTP_Username',MailAddress);
setpref('Internet','SMTP_Password',password);
sendmail(recipients,subject,message,attachments);
end
此处为,建立mailme函数来使用sendmail。查资料发现还要添加一处设定
修改后代码
function mailme(password,MailServer,MailAddress,recipients,subject,message,attachments)
setpref('Internet','E_mail',MailAddress);
setpref('Internet','SMTP_Server',MailServer);%SMTP服务器
setpref('Internet','SMTP_Username',MailAddress);
setpref('Internet','SMTP_Password',password);
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
sendmail(recipients,subject,message,attachments);
end
参考文献
链接: https://blog.youkuaiyun.com/a453712990/article/details/101781315.