Use My Python,Send Your Mail(十来行代码)
来源:互联网 发布:python tkinter opengl 编辑:程序博客网 时间:2024/05/18 02:35
人生苦短,我用python,最近实习一直在用工作,因为我做的工作涉及到海量数据,程序跑下来用上代理,一个月可能也跑不完,但是我快要回去考试两周,作为一个强迫症的coder,我必须要得知我的程序怎么了!!!所以我让我的程序成功执行一段时间,但是我又是非常“懒惰”的人(其实优秀的程序员都要很“懒惰”呢!坚决写简洁的代码,如果可以,越短越好,所以前短时间写了个160行的py 2048.),看了好多版本,看得我很郁闷呢~最后经过整理,得出这十行,送你!
import smtplib,refrom email.mime.text import MIMETextdef send (fromail,passwd,tomail,sub,info): msg = MIMEText(info) msg['Subject'] = sub msg['From'] = fromail smtp = smtplib.SMTP() p=re.compile(r'.*@(.*)') cn=p.findall(fromail)[0] smtp.connect(r'smtp.'+cn) smtp.login(fromail, passwd) smtp.sendmail(fromail,[tomail], msg.as_string()) smtp.close()
当我们调用的时候非常简单,就直接给定你的邮箱+密码,你寄送到的邮箱,主题,和内容信息,其中填写smtp那段我是用了简单的正则,免得麻烦,如果不正确自己固定写smtp.connect(r'smtp.yeah.net')之类,就可以把p,cn那两行删除。
比如
send('dengyaolong@yeah.net','密码','yaolongdeng@126.com','Use My Python','Send Your Mail')
1 0
- Use My Python,Send Your Mail(十来行代码)
- python smtp send mail
- python stmplib send mail
- python send mail
- Use Java Mail API to Send Email
- Android Use System Mail App to Send Mail
- use python implementation send email
- send mail by SMTP server (Python)
- SEND E-MAIL ASP.NET 发送E-Mail的代码
- send Mail
- Send mail
- Send mail
- SEND MAIL
- send mail
- send mail
- send mail
- SEND MAIL
- SharePoint server side code use Microsoft.Exchange.WebServices.dll send mail
- cheap toms online Koh siblings
- tiffany milano orari she said
- abercrombie online pipe Ming Fu also use this approach to fool other people
- 使用easyUI的datagrid显示查询得到的List<Object>对象
- 自顶向下分析Binder【1】—— Binder实例篇
- Use My Python,Send Your Mail(十来行代码)
- maven使用总结
- myeclipse上安装maven插件
- cryengine3中lua脚本模块集成笔记
- win7镜像下载
- 关于构建webx的时候运行mvn jetty:run出现无法打开C:\Users\GS\.m2\repository\commons-lang.2.4.jar的问题
- Android NDK环境搭建与配置说明
- 个性二维码生成
- 网络发送接收+移动端编程