献上python小程序一枚,不成敬意!
#!/usr/bin/python
#coding=utf-8
import time
import email
import smtplib
from email.mime.text import MIMEText
date=time.strftime(‘%Y-%m-%d %H:%M:%S‘,time.localtime())
sender=‘xxxxxxxx@163.com‘
receiver=‘874247458@qq.com‘
subject="Python 调试!!!"
username=‘xxxxxxxx@163.com‘
sendserver=‘smtp.163.com‘
password=‘************‘
msg=MIMEText(‘你好,欢迎使用Python!\n --苍狼牧\n %s‘%date)
msg[‘subject‘]=subject
msg[‘from‘]=sender
msg[‘receiver‘]=receiver
smtp=smtplib.SMTP()
smtp.connect(sendserver)
smtp.login(username,password)
smtp.sendmail(sender,receiver,msg.as_string())
smtp.quit()
print ‘OK!‘
输出OK!即执行完毕,邮件发送成功!
本文出自 “全球互联云主机Q874247458” 博客,请务必保留此出处http://gosweet.blog.51cto.com/11759495/1898799
原文地址:http://gosweet.blog.51cto.com/11759495/1898799