1 Star 0 Fork 0

Hey_m/some_t

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
send_email.py 926 Bytes
一键复制 编辑 原始数据 按行查看 历史
mlh 提交于 2024-04-09 23:51 . migrate
import os
import re
import smtplib
from email.mime.text import MIMEText
from email.header import Header
from email.utils import formataddr, parseaddr
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
def _format_addr(s):
name, addr = parseaddr(s)
return formataddr((Header(name, 'utf-8').encode(), addr))
smtp = smtplib.SMTP()
smtp.connect("smtp.163.com", port=25)
smtp.login(user="[email protected]", password="EOWSDJSDWWRDFDRW") # noqa
message = MIMEText('send_content', 'plain', 'utf-8')
sender = "agent<[email protected]>"
message['From'] = _format_addr(sender)
receivers = ["recv<[email protected]>"]
message['To'] = ','.join(list(map(_format_addr, receivers)))
message['Subject'] = Header('agent test failed notify.', 'utf-8') # 定义主题内容
smtp.sendmail(from_addr="[email protected]", to_addrs="[email protected]", msg=message.as_string())
print('send successfully')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/Hey_friends/some_t.git
[email protected]:Hey_friends/some_t.git
Hey_friends
some_t
some_t
master

搜索帮助