Python3 Send mail feature

Source: Internet
Author: User

a blog of-_-Han
  #首先写一个模块功能, e-mail feature packs up

fromSmtplibImportSMTP fromEmail.mime.textImportMimetextdefSend_email (smtp_host, from_addr, password, To_addrs, subject="', content="'): Email_client= SMTP (host=smtp_host) email_client.login (from_addr, password)#Create msgmsg= Mimetext (Content, _charset='Utf-8') msg['Subject'] =subject Email_client.sendmail (from_addr, To_addrs, msg.as_string ()) Email_client.quit ()
#-*-coding:cp936-*- fromMy_emailImportSend_emailif __name__=='__main__':    Try: Send_email ('smtp.163.com','[email protected]','xxxx','[email protected]','message Header','Message Content')        Print("sent successfully")    exceptException as E:Print(e)

Python3 Send mail feature

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.