Python implementation Send mail

Source: Internet
Author: User

Pip install. \YAGMAIL-0.10.212-PY2.PY3-NONE-ANY.WHL---installation yagmail


Import Yagmail

Username = ' [email protected] '

passwd = ' xxxxxxxxxxxx ' #邮箱授权码 (need to be set up in the mailbox)

Mail = Yagmail. SMTP (user=username,password=passwd,host= ' smtp.qq.com ', smtp_ssl=true)
#smtp. 163.com:163 mailbox, Smtp.qq.com:QQ mailbox, and add Smtp_ssl=true (Security protocol); SMTP.126.COM:126 mailbox

Mail.send (
to= ' [email protected] ', #如果有多个收件人的话, is written in list format
# cc= ' xxxxxxxxxx.qq.com ', #抄送
subject= ' Hello ', #邮件标题
Contents= ' Hello, did you have a good time today? ', #邮件正文
Attachments=[r ' C:\Users\Lynn\Desktop\test.txt ', R ' C:\Users\Lynn\Desktop\username.txt '] #发送附件, non-mandatory, when sending multiple attachments to a list Format
)

Print (' Send success ')

Python implementation 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.