This article is mainly for you to introduce the PYTHON3 implementation of the QQ mail function, text, with a certain reference value, Python3 interested in the small partners can refer to
This article for everyone to share the PYTHON3 implementation to send QQ Mail function: text, for your reference, the specific content as follows
Note: You need to set up the POP3 and IMAP service and set up a third-party authorization code before using it in QQ.
Then hit x below to fill in the relevant information
Import smtplibfrom email.mime.text import mimetextfrom email.utils import formataddrmy_sender= ' xxxx@qq.com ' # sender email account my _pass = ' xxxxxxx ' # Sender email password (at that time request SMTP password) my_user= ' xxxxxxxx@qq.com ' # Recipient email account, my side sent to myself Rdef Mail (): ret=true Try: msg=mimetext (' < mail content > ', ' Plain ', ' utf-8 ') msg[' from ']=formataddr (["xxxxxx", My_sender]) # Corresponding sender's mailbox nickname in parentheses, sender's email account msg[' to ']=formataddr (["xxxxxxx", My_user]) # corresponding recipient's mailbox nickname in parentheses, Recipient's email account msg[' Subject ']= ' mail subject ' # The subject of the message, also can be said to be the title Server=smtplib. Smtp_ssl ("smtp.qq.com", 465) # SMTP Server in the sender's mailbox, port is 465 server.login (My_sender, My_pass) # The corresponding in parentheses is the sender's mailbox account, email password server.sendmail (my_sender,[my_user,],msg.as_string ()) # in parentheses corresponding to the sender's mailbox account, the recipient's mailbox account, Send Message server.quit () # Close connection except exception:# if the statement in the try is not executed, the following Ret=false Ret=false return Retret=mail () is executed If Ret:print ("message sent successfully") Else:print ("message sent Failed")