Python简单实现邮件群发

Python简单实现邮件群发

        import smtplib
        from email.mime.text import MIMEText
        from email.utils import formataddr
          
        msg = MIMEText('xaaxaxaxafdjikgjhdjfg', 'plain', 'utf-8')
        msg['From'] = formataddr(["张三",'[email protected]'])
        msg['To'] = formataddr(["李四",'[email protected]'])
        msg['Subject'] = "邮件主题"
          
        server = smtplib.SMTP("smtp.126.com", 25) #端口
        server.login("zhangsan@126.com", "asdfadfsdfa")
        server.sendmail('[email protected]', ['[email protected]',‘[email protected]], msg.as_string())
        server.quit()

猜你喜欢

转载自www.cnblogs.com/bigtreei/p/9156330.html
今日推荐