office365 邮箱smtp报错

2021年8月12日 2806点热度 1人点赞 0条评论

问题描述

最近把域名邮件服务从网易切换到了 E5订阅office365 中的outlook,在使用smtp发送邮件时报错。主要有两种错误信息。

5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Mailbox. Visit https://aka.ms/smtp_auth_disabled for more information.

5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator.

解决方案

5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Mailbox. Visit https://aka.ms/smtp_auth_disabled for more information.

这个错误是因为邮件账户没开启smtp身份认证,全局管理员可以在Microsoft 365 admin center选择用户->活跃用户,点击用户列表中的邮件用户,右侧选择邮件,打开管理电子邮件应用,勾选经过身份认证的SMTP,最后保存更改。

5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator.

这个错误大概是因为邮件用户开启了多重认证,e5订阅默认开启了安全默认值,可以在 https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Properties 关闭。貌似关闭之后等待一段时间就可以使用smtp了。

如果还不行的话可以删除邮件用户的额外登陆方法。 https://mysignins.microsoft.com/security-info

修改完毕等待一段时间再试试,如果还不行,建议看看官方文档。

如何设置多功能设备或应用程序以使用 Microsoft 365 或 Office 365 发送电子邮件 | Microsoft Docs

其他

python3 outlook smtp发送邮件,参考别人的

import smtplib

from email.mime.text import MIMEText

from email.utils import formataddr



my_sender=''    # 发件人邮箱账号

my_pass = ''              # 发件人邮箱密码

my_user=''      # 收件人邮箱账号

def mail():

    ret=True

    try:

        msg=MIMEText('填写邮件内容','plain','utf-8')

        msg['From']=formataddr(["FromRunoob",my_sender])  # 括号里的对应发件人邮箱昵称、发件人邮箱账号

        msg['To']=formataddr(["FK",my_user])              # 括号里的对应收件人邮箱昵称、收件人邮箱账号

        msg['Subject']="菜鸟教程发送邮件测试"                # 邮件的主题,也可以说是标题



        server=smtplib.SMTP("smtp.office365.com", 587)  # 发件人邮箱中的SMTP服务器,端口是25

        server.ehlo()  # 发送SMTP 'ehlo' 命令

        server.starttls()

        server.login(my_sender, my_pass)  # 括号中对应的是发件人邮箱账号、邮箱密码

        server.sendmail(my_sender,[my_user,],msg.as_string())  # 括号中对应的是发件人邮箱账号、收件人邮箱账号、发送邮件

        server.quit()  # 关闭连接

    except Exception as e:  # 如果 try 中的语句没有执行,则会执行下面的 ret=False

        ret=False

        print(e)

    return ret



ret=mail()

if ret:

    print("邮件发送成功")

else:

    print("邮件发送失败")

KAMINO

这个人很懒,什么都没留下

文章评论