Created
July 14, 2018 12:41
-
-
Save ZJUGuoShuai/022df95731fa3aae0fc139f766eeb0aa to your computer and use it in GitHub Desktop.
Send email using Python 3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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