#!/usr/bin/env python
#coding=utf-8
import smtplib
from email.mime.text import MIMEText
host = "smtp.163.com"
port = 25
user = "xxxooo@163.com"
passwd = "xxxooo"
to = "xxxooo@gmail.com"
subject = "Testing SMTP Authentication"
content = "This mail tests SMTP Authentication"
#发件人地址
froms = user+'<%s>' %(user)
#处理发件内容
msg = MIMEText(content)
#处理发件主题
msg['Subject'] = subject
#处理发件人地址
msg['From'] = froms
#处理收件人地址
msg['To'] = to
#类实例化
s = smtplib.SMTP()
#连接邮件服务器
s.connect(host, port)
#登陆帐户跟密码
s.login(user, passwd)
#发送邮件内容
s.sendmail(froms, to, msg.as_string())
#退出登陆
s.close()
#显示发信成功
print 'OK!Successfuly'