from exchangelib import Credentials, Account, DELEGATE, Configuration, NTLM, Message, Mailbox, HTMLBody
from exchangelib.protocol import BaseProtocol, NoVerifyHTTPAdapter
import urllib3
urllib3.disable_warnings () # 取消SSL安全连接警告
# # Tell exchangelib to use this adapter class instead of the default
# # exchangelib provides a sample adapter which ignores TLS validation errors.
# # Use at own risk. NTML is NT LAN Manager.
BaseProtocol.HTTP_ADAPTER_CLS = NoVerifyHTTPAdapter
cred = Credentials ('域\\用户名', '密码') # 用户名不需要填写后缀
config = Configuration (
server='邮箱服务器', # 例如:mail.****.com
credentials=cred,
auth_type=NTLM
)
account = Account (
primary_smtp_address='你的邮箱地址', # 例如:ad@test.com
config=config,
autodiscover=False,</