【问题标题】:smtplib.SMTPAuthenticationError: (535, '5.7.3 Authentication unsuccessful') for office365.comsmtplib.SMTPAuthenticationError: (535, '5.7.3 Authentication unsuccessful') for office365.com
【发布时间】:2022-07-18 02:30:19
【问题描述】:

我正在尝试使用以下代码通过 python 脚本发送邮件

import smtplib


def print_hi(name):
    sender = 'my@mail.com'
    receivers = ['receiver@mail.com']

    message = """some msg"""

    server = smtplib.SMTP('smtp.office365.com', 587)
    server.set_debuglevel(1)
    server.starttls()
    server.ehlo()
    server.login("username", "password")
    server.sendmail(sender, receivers, message)
    server.quit()


if __name__ == '__main__':
    print_hi('PyCharm')

我收到以下错误:

  raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator. [BM1PR01CA0144.INDPRD01.PROD.OUTLOOK.COM]')

我查看了许多 StackOverflow 问题和 Microsoft 博客,并获得了以下步骤来为我们的组织启用 SMTP:

  1. 启用 SMTP 身份验证(已启用)
  2. 检查安全默认值(我们无法禁用它,因为它会禁用所有 MFA,这在组织级别不符合要求)

因此,如果有人知道如何使其工作,请牢记所有安全性,这将是有帮助的!

【问题讨论】:

标签: python email security smtp office365


【解决方案1】:

不太安全的应用和您的 Google 帐户 为帮助确保您的帐号安全,自 2022 年 5 月 30 日起,Google 不再支持使用第三方应用或设备,这些应用或设备要求您仅使用您的用户名和密码登录您的 Google 帐号。

重要提示:此截止日期不适用于 Google Workspace 或 Google Cloud Identity 客户。这些客户的执行日期将在稍后的 Workspace 博客上公布。

更多信息,请继续阅读。

您好,我也面临同样的问题。并且 Google 已阻止与第三方的任何联系。

【讨论】:

    猜你喜欢
    • 2016-04-11
    • 1970-01-01
    • 2016-01-19
    • 2021-10-13
    • 1970-01-01
    • 2019-01-26
    • 2018-01-01
    • 2021-12-10
    • 1970-01-01
    相关资源
    最近更新 更多