Python e-mail

Source: Internet
Author: User

ImportSmtplib fromEmail.mime.textImportMimetext fromEmail.headerImportHeader#third-party SMTP servicesmail_host="smtp.qq.com"  #setting up the serverMail_user="xxxxxx"    #User namemail_pass="Plcfthkdtpoxcabh"   #password QQ requires authorization codeSender='[email protected]'Receivers= ['[email protected]']#receive mail, can be set as your QQ mailbox or other mailboxmessage= Mimetext ('Python Mail send content test ...','Plain','Utf-8') message[' from'] = Header ("This writes the name of the sender.",'Utf-8') message[' to'] = Header ("This is the recipient name",'Utf-8') Subject='Python SMTP Mail test-Topics'message['Subject'] = Header (subject,'Utf-8')Try: Smtpobj=Smtplib. Smtp_ssl () smtpobj.connect (Mail_host,465)#465 is the SMTP port numberSmtpobj.login (Mail_user,mail_pass)Print(Help (Smtpobj.sendmail)) Smtpobj.sendmail (sender, Receivers, message.as_string ())Print("message sent successfully")exceptSmtplib. Smtpexception:Print("Error: Unable to send message")

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