Send mail function

Source: Internet
Author: User
Tags email account

Python's ability to send mail

1 ImportSmtplib2  fromEmail.mime.textImportMimetext3  fromEmail.utilsImportformataddr4 5 #Send mail feature6 defSend_mail (send_message_txt,*senders_list,**send_to_people):7Flag =True8     Try:9         #Write the content you sendTenSend_msg = Mimetext (Send_message_txt,"Plain","Utf-8") Onesend_msg[" from"] = FORMATADDR (["Sender's name","Email Account"]) A         #F List of senders -          forSender_name,mail_addressinchSend_to_people.items (): -send_msg[" to"] =formataddr ([sender_name,mail_address]) the         Else: -             Print("Add all Senders") -send_msg["Subject"] ="the Sqlmap file contents of the exception occurred" -         #Log on to the mailbox server +Send_server = Smtplib. SMTP ("smtp.126.com", 25) -Send_server.login ("Login Email Account","Email Password") +         #Send mail ASend_server.sendmail ("[email protected]", Senders_list,send_msg.as_string ()) at send_server.quit () -     exceptException as E: -         Print(e) -Flag =False -     returnFlag

Send mail function

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.