赞
踩
python群发送邮件需要使用到smtplib,email
- import smtplib
- from email.mime.text import MIMEText
- from email.header import Header
smtplib是用来发送邮件用的,email是用来构建邮件内容的。这两个都是Python内置模块
这次代码所需要的函数有
- server = smtplib.SMTP()
- server.connect(host, port)
- server.login(username, password)
- server.sendmail(sender, to_addr, msg.as_string())
- server.quit()
SMTP是一种提供可靠且有效的电子邮件传输的协议,有印象即可
t(host,port):指定服务器,host是服务器(域名)地址,port是对应的服务器端口
以QQ邮箱为例子 host:smtp.qq.com
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。