This article mainly introduces the python mail sending function implementation code, which has some reference value. interested friends can refer to the examples in this article to share 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 to everyone's learning, and I hope you can support your own home.