PYTHON-QQ Mailbox Send mail

Source: Internet
Author: User

You can try it and use it to send an email after the error

#!/usr/bin/env Python3

#-*-Coding:utf-8-*-

From Email.header Import Header

From Email.mime.text import Mimetextimport smtplib

#username = "[Email protected]"

Password = "Authorization Code"

#授权码在QQ邮箱设置-Open under Account

FROM_ADDR = "[Email protected]"

TO_ADDR = "[Email protected]"

Smtp_server = "Smtp.qq.com"

msg = Mimetext (' Hello, send by Python ... ', ' plain ', ' utf-8 ')

msg[' from ' = Header ("Ppyy", ' Utf-8 ')

msg[' to ' = Header ("You", ' Utf-8 ')

msg[' Subject ' = Header (' Greetings from SMTP ... ', ' utf-8 ')

Try

Server = Smtplib. Smtp_ssl (smtp_server,465)

Change #如果不是Qq smtp.qq.com to localhost

Server.login (from_addr, password)

Server.sendmail (From_addr, to_addr,msg.as_string ())

Server.quit ()

Print ("Success")

Except Smtplib. Smtpexception:

Print ("Unsuccess")


PYTHON-QQ Mailbox Send mail

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.