# send_mail.py
#coding: Utf-8
Import Smtplib
From Email.mime.text import Mimetext
From Email.header Import Header
# Third-party SMTP service
Mail_host= "smtp.qq.com" #设置服务器, QQ mailbox, 163 mailbox (smtp.163.com), self-built mailbox
mail_user= "User name" #用户名
mail_pass= "Authorization Code" #口令, QQ Mailbox/163 mailbox is the input authorization code, such as in the mailbox set up with the verified mobile phone to send text messages, without spaces.
Sender = ' sender qq.com ' # sender
receivers = [' recipient [email protected] ', ' recipient [email protected] ', ' recipient [email protected] ' # recipient
# Send Message subject
Subject = ' Python email test '
# Write HTML-type message body
msg = Mimetext ('
msg[' Subject ' = Header (Subject, ' utf-8 ')
Msg[' from '] = ' sender @qq.com '
msg[' to ' = ' recipient [email protected], recipient [email protected] '
msg[' Cc '] = ' recipient [email protected] '
# Connect to send mail
Smtpobj = Smtplib. Smtp_ssl (Mail_host)
Smtpobj.login (Mail_user,mail_pass)
Smtpobj.sendmail (sender, Receivers, msg.as_string ())
Smtpobj.quit ()
Python Send mail