Python mail sending function implementation code, python mail sending code

Source: Internet
Author: User
Tags email account

Python mail sending function implementation code, python mail sending code

The example in this article shares the python mail simplified code for your reference. The specific content is as follows:

Import smtplibfrom email. mime. text import MIMETextfrom email. utils import formataddr # send mail function def send_mail (send_message_txt, * senders_list, ** send_to_people): flag = True try: # Write the sent content send_msg = MIMEText (send_message_txt, "plain ", "UTF-8") send_msg ["From"] = formataddr (["sender name", "email account"]) # f sender list for sender_name, mail_address in send_to_lele.items (): send_msg ["To"] = formataddr ([sender_name, mail_address]) else: print ("add all senders ") send_msg ["Subject"] = "abnormal sqlmap file content" # log on to the mailbox server send_server = smtplib. SMTP ("", 25) send_server.login ("Login mailbox account", "Mailbox password") # send mail send_server.sendmail ("", senders_list, send_msg.as_string () send_server.quit () failed t Exception as e: print (e) flag = False return flag

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

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: 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.