渐渐地,那原本被夜幕笼罩的天空出现了微明。一颗颗启明星逐渐变得苍白无力,在浅浅的日光的照射下,胆怯的它们终于退却了。随着启明星的消失,害羞的太阳射出了几道耀眼的金光。
本文实例为大家分享了python发邮件精简代码,供大家参考,具体内容如下
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(["发送人姓名","邮箱账号"]) #f发送人的名单 for sender_name,mail_address in send_to_people.items(): send_msg["To"] = formataddr([sender_name,mail_address]) else: print("添加所有发送人") send_msg["Subject"] = "出现异常的sqlmap文件内容" #登录邮箱服务器 send_server = smtplib.SMTP("smtp.126.com",25) send_server.login("登录邮箱账号","邮箱密码") #发送邮件 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
到此这篇关于python发送邮件功能实现代码就介绍到这了。山涧的泉水经过一曲折,才唱出一支美妙的歌。更多相关python发送邮件功能实现代码内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!