格式的,设定格式:普通文本,或者html
msg.attach(MIMEText('{}'.format(message), 'html', 'utf-8'))
6....,那就需要读取本地附件,然后进行发送
from email import encoders
from email.mime.base import MIMEBase
try:
# 添加附件就是加上一个...MIMEBase,从本地读取一个文件,child文件的路径
with open(child, 'rb') as f:
# 设置附件的MIME和文件名
mime = MIMEBase('file...格式的,设定格式:普通文本,或者html
msg.attach(MIMEText('{}'.format(self.html), 'html', 'utf-8'))
try...except Exception as e:
print("发送邮件失败,错误原因:{}".format(repr(e)))
# 发送邮件模块 增加附件