This article is mainly for you to introduce the PYTHON3 implementation of the QQ mail function, the HTML format of the QQ Mail, with a certain reference value, Python3 interested in the small partners can refer to this article, this article for everyone to share the Python3 to achieve the QQ mail function: HTML, For your reference, the specific contents are as follows
QQ Mail has been successfully sent before. The following posted in HTML format QQ mail
Import smtplibfrom email.mime.text import mimetextfrom email.utils Import formataddrmy_sender = ' xxxxxxx@qq.com ' # sender's mailbox account Number My_pass = ' xxxx ' # Sender's mailbox password (at that time request smtp password) My_user = ' xxxxxx@qq.com ' # recipient mailbox account, my side sends to myself RDEF Mail (): ret = True Try : mail_msg = "" "<p>python Mail Send test ... </p><p><a href=" http://www.baidu.com "rel=" External nofollow " > This is a link </a></p> "" "Msg=mimetext (mail_msg, ' html ', ' Utf-8 ') # msg=mimetext (' < mail content > ', ' Plain ', ' UT F-8 ') msg[' from ']=formataddr (["xxxxx", My_sender]) # corresponding sender's mailbox nickname in parentheses, Sender's mailbox account msg[' to ']=formataddr (["xxxxx", My_use R]) # The corresponding recipient's mailbox nickname in parentheses, the recipient's email account msg[' Subject ']= ' mail subject ' # The subject of the message, it can also be said that the title server=smtplib. Smtp_ssl ("smtp.qq.com", 465) # The SMTP server in the sender's mailbox, the port is 465 server.login (My_sender, my_pass) # brackets correspond to the sender's mailbox account, email password Server.sendmail (My_sender, [My_user,], msg.as_string ()) # in parentheses corresponds to the sender's mailbox account, recipient's email account, outgoing mail server.quit () # Close connection except Exception: # If the statement in the try is not executed, the following ret= is executedFALSE ret = false return Retret = Mail () If Ret:print ("message sent successfully") Else:print ("message sent Failed")