import exchangelib
from exchangelib import DELEGATE, Account, Credentials, Message, Mailbox, HTMLBody
Account1 = 'wzscnZ1809****'
Password = '****'
credentials = Credentials(Account1, Password)
account = Account(primary_smtp_address='S****_H****@wistron.com', credentials=credentials, autodiscover=True, access_type=DELEGATE)
subject = 'Python测试发送邮件'
body = 'Dear, 这是python自动发送邮件测试'
Recipients = ['S****_Z****@wistron.com']
for receiver in Recipients:
Message1 = Message(account=account, subject=subject, body=HTMLBody(body), to_recipients=[Mailbox(email_address=receiver)])
Message1.send()
print('发送成功')
安装模块
pip install yagmail keyring --user
pip install exchangelib



