1、首先下载一个神器exchangelib,操作 pip install exchangelib

2、然后只需要将下面的信息改成你的信息就可以了

from exchangelib import Account, Message, Mailbox, HTMLBody, ServiceAccount
#忽略警告
import urllib3
urllib3.disable_warnings()

#报错处理:ConnectionError: HTTPConnectionPool(host='mail.xxx.com', port=443): Max retries exceeded with url:
# import socket
# socket.create_connection((host, port), timeout=10)

def Email(to, subject, body):
creds = ServiceAccount(username='域\名', password='密码')
account = Account('发送的邮箱', credentials=creds, autodiscover=True)
m = Message(account=account,subject=subject,body=HTMLBody(body),
to_recipients = [Mailbox(email_address=to)]
)
m.send()

Email("接收的邮箱", "邮件标题", "邮件内容")
 

相关文章:

  • 2021-09-17
  • 2021-09-18
  • 2021-10-30
  • 2021-05-27
  • 2021-05-01
猜你喜欢
  • 2021-07-14
  • 2021-12-23
  • 2022-12-23
  • 2021-12-12
  • 2021-12-02
  • 2021-05-01
  • 2022-12-23
相关资源
相似解决方案