The example of this article for you to share the Python email streamlined code for your reference, the specific contents are as follows
Import Smtplib from
email.mime.text import mimetext from
email.utils import formataddr
#发送邮件功能
def Send_mail (send_message_txt,*senders_list,**send_to_people):
flag = True
try:
#编写发送的内容
send_msg = Mimetext (Send_message_txt, "plain", "Utf-8")
send_msg["from"] = formataddr (["Sender name", "Mailbox Account"])
#f发送人的名单 For
sender_name,mail_address in Send_to_people.items ():
send_msg["to"] = FORMATADDR ([sender_name,mail_ Address]
Else:
print ("Add all Senders")
send_msg["Subject" = "Unexpected Sqlmap file contents"
#登录邮箱服务器
Send_ Server = Smtplib. SMTP ("smtp.126.com")
send_server.login ("Login mailbox Account", "Mailbox Password")
#发送邮件
send_server.sendmail (" Zqgcy0808@126.com ", senders_list,send_msg.as_string ())
send_server.quit ()
except Exception as E:
Print (e)
flag = False return
flag
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.