# -*- coding: utf-8 -*- from email.header import Header from email.mime.text import MIMEText import smtplib def sendmail(subject, content): sender = '' # 发件人邮箱 password = '' # 发件人邮箱密码 recipients = '' # 收件人邮箱 host = '' # 发件人邮箱主机 msg = MIMEText(content, 'plain', 'utf-8') msg['From'] = sender msg['To'] = recipients msg['Subject'] = Header(subject, 'utf-8').encode() server = smtplib.SMTP(host, 25) server.login(sender, password) server.sendmail(sender, [recipients], msg.as_string()) server.quit()
如果您觉得我的文章对您有帮助并想鼓励我继续原创,请扫描下方二维码进行打赏!
谢谢!