Python3群发邮件

import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr

def how_to_send():
    account='[email protected]'# 发件人
    account_password = 'password'#邮箱密码
    recevier=['[email protected]']#如果有多个收件人,就在列表中添加一项
    msg=MIMEText('内容','plain','utf-8')
    msg['Subject']="这里是标题" 
    send_email=smtplib.SMTP_SSL("smtp.qq.com", 465)
    send_email.login(account, account_password)
    send_email.sendmail(account,recevier,msg.as_string())
    send_email.quit()  # 关闭连接
if __name__ == '__main__':
    how_to_send()

你可能感兴趣的:(Python3群发邮件)