Mail function, java mail function

Source: Internet
Author: User

Mail function, java mail function

Python mail function

1 import smtplib 2 from email. mime. text import MIMEText 3 from email. utils import formataddr 4 5 # mail sending function 6 def send_mail (send_message_txt, * senders_list, ** send_to_people): 7 flag = True 8 try: 9 # Write the sent content 10 send_msg = MIMEText (send_message_txt, "plain", "UTF-8") 11 send_msg ["From"] = formataddr (["sender name ", "email account"]) 12 # f sender list 13 for sender_name, mail_address in send_to_lele.items (): 14 send_msg ["To"] = formataddr ([sender_name, mail_address]) 15 else: 16 print ("add all senders") 17 send_msg ["Subject"] = "abnormal sqlmap file content" 18 # log on to the mailbox server 19 send_server = smtplib. SMTP ("smtp.126.com", 25) 20 send_server.login ("Login mailbox account", "Mailbox password") 21 # send mail 22 send_server.sendmail ("zqgcy0808@126.com", senders_list, send_msg.as_string ()) 23 send_server.quit () 24 handle T Exception as e: 25 print (e) 26 flag = False27 return flag

 

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.