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 ("smtp.126.com", 25) send_server.login ("Login mailbox account", "Mailbox password") # send mail send_server.sendmail ("zqgcy0808@126.com", 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.