Python Mail Send source code

Source: Internet
Author: User

From the initial implementation of the mail delivery function, changed a few times, with the following code.

The code can also continue to develop and refine. To achieve more complex functionality.

#-*-coding:utf-8-*-i = 0while i < 10:import smtplib from  email.mime.text import mimetext from  Email.header im Port Header  Import time# third-party SMTP service  mail_host= "smtp.qq.com"  #设置服务器  mail_user= "[Email protected]"    #发件人用户名  mail_pass= "Awlnfypgaznfbbhz"   #发件人口令, QQ mailbox is the input authorization code, in the QQ mailbox set up with a verified mobile phone to send text messages, not including the space  sender = ' [ Email protected] ' #与发件人用户名保持一致receivers = "[email protected]"  # Recipient email address, can be set to your QQ mailbox or other mailbox  message = Mimetext ( ' Content ', ' plain ', ' utf-8 ')  message[' from ' = Header ("Sender", ' Utf-8 ')  message[' to '] =  header ("You", ' Utf-8 ') )  subject = ' title '  message[' subject ' = header (subject, ' utf-8 ')  try:  smtpobj = Smtplib. Smtp_ssl (Mail_host, 465)   Smtpobj.login (mail_user,mail_pass)    smtpobj.sendmail (sender, receivers, Message.as_string ())  smtpobj.quit ()  print u "Mail sent successfully"  except Smtplib. Smtpexception,e:  Print ei = i + 1time.sleep (' End ')

  

Python Mail Send source code

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.