Gmail发送问题

发布于 2025-02-09 12:40:31 字数 279 浏览 2 评论 0 原文

“在此处输入映像说明”

所以我尝试自动发送gmail,但是由于错误,在检查后,它因错误而失败,用户名和通行证是真实的。因此,我想问一下是否有任何错误可能导致此错误。

“在此处输入映像”

这是我的代码,端口是465,我不希望有人知道我的通行证和我的用户名。

enter image description here

So i try smtplib to send gmail automatically, however it fail because of a error, after some checking, my username and pass are True. So i want to ask if there were any mistakes that can lead to this error.

enter image description here

Here is my code, the port is 465 and i don't want anyone know my pass and my username.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

噩梦成真你也成魔 2025-02-16 12:40:31

错误消息<代码>“未接受的用户名和密码” 是发送用户实际的Google密码时从SMTP服务器中获取的标准错误消息。

SMTP服务器(2022年5月30日)无法接受这种身份验证方法。部分原因是删除 secure Secure Apps&amp&amp;您的Google帐户主要是因为客户登录不被认为是安全的。

您的选项是在我们的Google帐户上启用2FA并使用并创建 。只需在代码中使用它代替密码即可。

smtp.login(username, appsPasswrod)

或使用 xoauth2 并对应用程序进行了认证。

The error message "username and password not accepted" is the standard error message you get from the smtp server when sending the users actual google password.

This method of authentication is not acceptable by the SMTP server after (May 30, 2022). Partially due to the removal of Less secure apps & your Google Account mostly because client login is not considered to be secure.

Your options are to to enable 2fa on our google account and use and create an apps password. Simply use it in place of the password in your code.

smtp.login(username, appsPasswrod)

Or to use XOauth2 and authenticate the application.

全部不再 2025-02-16 12:40:31

创建一个sendemail()函数,该功能将通过调用该功能来帮助将电子邮件发送给一个或多个收件人。

def sendEmail(to, content):
    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.ehlo()
    server.starttls()
    server.login('[email protected]', 'your-password')
    server.sendmail('[email protected]', to, content)
    server.close()
content = "Message to send"
to = "[email protected]"    
sendEmail(to, content)

注意: 不要忘记确保smtplib需要在Gmail帐户中“启用较不安全的应用程序”功能。否则,sendemail功能将无法正常工作。

创建应用程序密码: /a>

Create a sendEmail() function, which will help to send emails to one or more than one recipient by calling the function.

def sendEmail(to, content):
    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.ehlo()
    server.starttls()
    server.login('[email protected]', 'your-password')
    server.sendmail('[email protected]', to, content)
    server.close()
content = "Message to send"
to = "[email protected]"    
sendEmail(to, content)

NOTE: Do not forget to make sure that the smtplib requires 'enable the less secure apps' feature in your Gmail account. Otherwise, the sendEmail function will not work properly..

Create App Password: App Passwords

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文