python 3.6.3 , use QQ mailbox to send mail

Sample code:

    

#coding=utf-8
import smtplib
from email.mime.text import MIMEText

msg_from='[email protected]'
passwd='*****' #This is not the QQ password, it is the authorization code provided when applying for POP3/SMTP service
msg_to='[email protected]'
                            
subject = "python mail test"
content = "This is the email I sent using python smtplib and the email module"

msg = MIMEText(content)
msg['Subject'] = subject
msg['From'] = msg_from
msg['To'] = msg_to
#try:
s = smtplib.SMTP_SSL("smtp.qq.com",465)
s.login(msg_from, passwd)
s.sendmail(msg_from, msg_to, msg.as_string())
print("Send successfully")


 
 






Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325853609&siteId=291194637