# -*- coding: UTF-8 -*- import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText msg = MIMEMultipart() msg["From"] = "fuhanw@qq.com" msg["To"] = "fuhanw@foxmail.com" msg["Subject"] = "这是一封来自Python的邮件" text = MIMEText("这是一封来自Python的邮件 这是一封来自Python的邮件 这是一封来自Python的邮件") msg.attach(text) smtp = smtplib.SMTP() smtp.connect("smtp.qq.com", "25") smtp.login("fuhanw@qq.com", "xxxxxxxx") smtp.sendmail("fuhanw@qq.com", "fuhanw@foxmail.com", msg.as_string()) smtp.quit()