Python3 implement Send QQ mail function (HTML) _python

Source: Internet
Author: User
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") 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.