import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
def how_to_send():
account='username@qq.com'# 发件人
account_password = 'password'#邮箱密码
recevier=['username@qq.com']#如果有多个收件人,就在列表中添加一项
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()
网友评论