验证中...
Languages: Python
Categories: Web开发技术
Latest update 2019-12-03 14:02
email_send
Raw Copy
import time
import smtplib
from email.mime.text import MIMEText
from email.header import Header
def send():
time.sleep(1)
content='test'
user_s = 'vip@***.vip'
passwd_s = 'M***'
Subject = 'Python SMTP 邮件测试'
to_list_s = ['69***@qq.com']
attach = MIMEText(content, 'html', 'utf-8')#内容
attach['From'] = Header("证件照", 'utf-8') # 发送者
attach['Subject'] = Header(Subject, 'utf-8')#标题
attach["To"] = ";".join(to_list_s)#收件人列表
attach.as_string()
try:
server = smtplib.SMTP_SSL("smtp.exmail.qq.com", port=465)
server.login(user_s,passwd_s)
server.sendmail(user_s,to_list_s, attach.as_string())
server.close()
print("send email successful")
except Exception as e:
print("send email failed %s" % e)
if __name__ == '__main__':
send()

Comment list( 0 )

Sign in for post a comment

Help Search