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