1 Star 0 Fork 46

lipl/qytang_Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
2016.1.24 SMTPLIB发送邮件 750 Bytes
一键复制 编辑 原始数据 按行查看 历史
现任明教教主-乾颐堂 提交于 2016-01-24 21:53 . new file
import smtplib, sys, email.utils
mailserver = 'smtp.163.com'
user = 'collinsctk@163.com'
password = 'xxxxx'
From = input('From? ').strip()
To = input('To? ').strip()
Tos = To.split(';')
Subj = input('Subj? ').strip()
Data = email.utils.formatdate()
text = ('From: %s\nTo: %s\nData: %s\nSubject: %s\n\n' % (From, To, Data, Subj))
print('Type message text, end with line = [Ctrl+d (Unix), Ctrl+z (Windows)]')
while True:
line = sys.stdin.readline()
if not line:
break
text += line
print('Connecting...')
server = smtplib.SMTP(mailserver)
server.login(user, password)
failed = server.sendmail(From, Tos, text)
server.quit()
if failed:
print('Falied recipients:', failed)
else:
print('No errors.')
print('Bye.')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/lipl/qytang_Python.git
git@gitee.com:lipl/qytang_Python.git
lipl
qytang_Python
qytang_Python
master

搜索帮助