标签:dma 内容 position name email int 附件 xxxxx 邮件服务器
def send_email(str):
fromaddr = ‘xxxxxxxxx@qq.com‘ # 发送方邮箱
password = ‘xxxxxxxxx‘ # 填入发送方邮箱的授权码
toaddrs = [str] # 收件人邮箱
content = ‘最新生成内容‘
textApart = MIMEText(content)
zipFile = file_dir + ‘/aa_file.zip‘
zipApart = MIMEApplication(open(zipFile, ‘rb‘).read())
zipApart.add_header(‘Content-Disposition‘, ‘attachment‘, filename=‘QianBi.zip‘)
m = MIMEMultipart()
m.attach(textApart)
m.attach(zipApart)
m[‘Subject‘] = ‘千币分析‘
try:
s = smtplib.SMTP_SSL("smtp.qq.com", 465) # 邮件服务器及端口号
s.login(fromaddr, password)
s.sendmail(fromaddr, toaddrs, m.as_string())
print(‘success‘)
s.quit()
except smtplib.SMTPException as e:
print(‘error:‘, e)
if __name__ == ‘__main__‘:
send_email()
标签:dma 内容 position name email int 附件 xxxxx 邮件服务器
原文地址:https://www.cnblogs.com/ioswws/p/10072383.html