First of all to know the use of Python agent login QQ mailbox Email, it is necessary to change their QQ mailbox settings. Here are two things to do: The mailbox opens SMTP function, obtains the authorization Code tutorial link.
After the implementation of the use of Python login QQ email sent QQ Mail, to use to email and smtplib Library
From Email.mime.text import Mimetext to
email.header import header from
smtplib import Smtp_ssl
# QQ Mailbox SMTP Server
host_server = ' smtp.qq.com '
#sender_qq为发件人的qq号码
sender_qq = ' 78**315** '
#pwd为qq邮箱的授权码
pwd = ' i**k**cl**q*b**d '
#发件人的邮箱
sender_qq_mail = ' 78**315** @qq. com '
#收件人邮箱
receiver = ' 13**8 *0**0@qq.com '
#邮件的正文内容
mail_content= ' "Hello, I am a passerby, now in a python login qq email mail test" ""
#邮件标题
Mail _title = ' This is a test email! '
#ssl登录
smtp = Smtp_ssl (host_server)
#set_debuglevel () is used for debugging. A parameter value of 1 indicates that debug mode is turned on, and the parameter value is 0 off debug mode
smtp.set_debuglevel (1)
Smtp.ehlo (host_server)
Smtp.login (SENDER_QQ, PWD)
msg = Mimetext (mail_content, "plain", ' utf-8 ')
msg["Subject"] = Header (mail_title, ' utf-8 ')
msg[" From '] = Sender_qq_mail
msg["to" = Receiver
smtp.sendmail (sender_qq_mail, receiver, msg.as_string ())
Smtp.quit ()
Simply change the data such as Host_server, SENDER_QQ, pwd, Sender_qq_mail, receiver, Mail_content, Mail_title, and so on, to achieve a simple send task.