Created
March 17, 2016 11:06
-
-
Save sunliwen/fa0aade25909f7ad41b2 to your computer and use it in GitHub Desktop.
smtplib ssl qq mail
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 os, sys | |
import smtplib | |
from smtplib import SMTP_SSL | |
from email.header import Header | |
from email.mime.text import MIMEText | |
mailInfo = { | |
"from":"[email protected]", | |
"to":"[email protected]", | |
"hostname":"smtp.exmail.qq.com", | |
"username":"USERNAME", | |
"password":"PASSWORD", | |
"mailsubject":"Title", | |
"mailtext":"Hello World!", | |
"mailencoding":"utf-8" | |
} | |
if __name__ == '__main__': | |
smtp = SMTP_SSL(mailInfo["hostname"]) | |
smtp.set_debuglevel(1) | |
smtp.ehlo(mailInfo["hostname"]) | |
smtp.login(mailInfo["username"],mailInfo["password"]) | |
msg = MIMEText(mailInfo["mailtext"],"text",mailInfo["mailencoding"]) | |
msg["Subject"] = Header(mailInfo["mailsubject"],mailInfo["mailencoding"]) | |
msg["from"] = mailInfo["from"] | |
msg["to"] = mailInfo["to"] | |
smtp.sendmail(mailInfo["from"], mailInfo["to"], msg.as_string()) | |
smtp.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment