xlwings学习者 2022-12-07 11:43 采纳率: 25%
浏览 598
已结题

python的exchangelib 报错,我需要oauth的认证详解

公司升级了outlook MFA认证,

python的exchangelib 报错

from exchangelib import DELEGATE, Account, Credentials, Message, Mailbox, HTMLBody,FileAttachment,Configuration,NTLM
from exchangelib.protocol import BaseProtocol,NoVerifyHTTPAdapter
BaseProtocol.HTTP_ADAPTER_CLS = NoVerifyHTTPAdapter

def Email(to,cc_mail,subject, body, attachmentspath=None):
    
    creds = Credentials(
        username='xxx@bbbb.com',  # 账号
        password='**********'  # 密码
    )

    account = Account(
        primary_smtp_address='xxx@bbbb.com',  # 发送方邮箱地址
        credentials=creds,
        autodiscover=True,
        access_type=DELEGATE
    )
    m = Message(
        account=account,
        cc_recipients=cc_mail,
        subject=subject,
        body=HTMLBody(body),
        to_recipients=[Mailbox(email_address=to)]
    )

报错
raise AutoDiscoverFailed(
exchangelib.errors.AutoDiscoverFailed: All steps in the autodiscover protocol failed for email xxx@bbbb.com. If you think
this is an error, consider doing an official test at https://testconnectivity.microsoft.com
  • 写回答

6条回答 默认 最新

  • 宁神笔记 2022-12-07 15:36
    关注

    这个错误消息表明,在尝试自动发现 Exchange 服务器时失败了。通常,这种情况发生在以下几种情况:

    你输入的电子邮件地址有误,无法找到对应的 Exchange 服务器。
    你输入的电子邮件地址对应的 Exchange 服务器当前不可用。
    你的程序无法连接到 Exchange 服务器,可能是因为网络问题或者防火墙设置。
    如果你遇到了这种情况,建议你检查电子邮件地址是否正确,并检查网络连接是否正常。如果仍然无法解决问题,可以尝试使用官方测试工具(https://testconnectivity.microsoft.com)来检测 Exchange 服务器的连接情况。

    评论

报告相同问题?

问题事件

  • 系统已结题 12月15日
  • 修改了问题 12月7日
  • 赞助了问题酬金200元 12月7日
  • 修改了问题 12月7日
  • 展开全部