gpt4 book ai didi

matlab - 为什么在 matlab 中源发送邮件 (gmail) 不起作用?

转载 作者:行者123 更新时间:2023-12-04 19:42:46 24 4
gpt4 key购买 nike

我想在 MATLAB R2015a 中通过 Gmail 发送电子邮件。这是我的代码:

my_default_email_address = 'mygmail@gmail.com';
my_username = 'mygmail';
my_password = 'mypass';

setpref('Internet','E_mail',my_default_email_address);
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username',my_username);
setpref('Internet','SMTP_Password',my_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');
sendmail('recipient@example.com' , 'subject of the email', 'text of the email');

但它不起作用并返回以下错误:

Error using send mail (line 171) Authentication failed.

Error in email (line 14) sendmail('recipient@example.com' , 'subject of the email', 'text of the email');

我什至在浏览器中打开并登录了我的 Gmail,但它仍然会抛出此错误。谁能帮帮我?

最佳答案

我相信您的用户名也应该包括域名。将 my_username 设置为 mygmail@gmail.com 并重试。

修改:确保打开安全性较低的应用程序的访问权限。阅读更多 here .

关于matlab - 为什么在 matlab 中源发送邮件 (gmail) 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33723074/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com