Skip to content

Instantly share code, notes, and snippets.

@ZJUGuoShuai
Created July 14, 2018 12:41
Show Gist options
  • Save ZJUGuoShuai/022df95731fa3aae0fc139f766eeb0aa to your computer and use it in GitHub Desktop.
Save ZJUGuoShuai/022df95731fa3aae0fc139f766eeb0aa to your computer and use it in GitHub Desktop.
Send email using Python 3.
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from_addr = "[email protected]"
to_addr = "[email protected]"
msg = MIMEMultipart()
msg['From'] = from_addr
msg['To'] = to_addr
msg['Subject'] = "测试发送"
body = "最近过得怎么样?"
msg.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP('smtp.163.com', 25)
server.ehlo()
server.starttls()
server.ehlo()
server.login("msn4399", "password")
text = msg.as_string()
server.sendmail(from_addr, to_addr, text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment