嘿嘿,看了java mail实现邮件发送,虽然有会用了但是有两个小小的问题还不清楚。
尝试用python实现一下邮件发现。
首先看到的是这篇文章。http://www.cnblogs.com/lonelycatcher/archive/2012/02/09/2343463.html
就是简单发送的代码。试了一下果然可以。呼呼~~~
然后具体看一下这个模块的使用方法:
http://www.cnblogs.com/xiaowuyi/archive/2012/03/17/2404015.html
简单的text文件这样就可以:
#encoding: utf-8
import smtplib
from email.mime.text import MIMEText
from email.header import Header
sender = '*********@163.com'
receiver = '********@qq.com'
subject = 'Test-Python-Mail'
smtpserver = 'smtp.163.com'
username = '*****@163.com'
password = '********'
content = 'This email is sended to validate the python main kit.just for fun test,3Q for your cooperation!'
msg = MIMEText(content,'text','utf-8')
msg['Subject'] = Header(subject,'utf-8')
smtp = smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.login(username,password)
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()
print 'your email send done!'