Created
July 14, 2018 12:41
-
-
Save AtomicVar/022df95731fa3aae0fc139f766eeb0aa to your computer and use it in GitHub Desktop.
Send email using Python 3.
This file contains 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 = "msn4399@163.com" | |
to_addr = "httpggg@qq.com" | |
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