#!/usr/bin/env python
#encoding=utf8
#coding=utf-8
import smtplib, sys
reload(sys)
sys.setdefaultencoding('utf8')
from email.mime.text import MIMEText
msg_from='linuxdxw@163.com' #发送方邮箱
passwd='hahaha' #填入发送方邮箱的授权码
msg_to='1536175386@qq.com' #收件人邮箱
subject="python邮件测试" #主题
fileObj = open('/root/port.txt')
content=fileObj.read()
msg = MIMEText(content)
msg['Subject'] = subject
msg['From'] = msg_from
msg['To'] = msg_to
#try:
s = smtplib.SMTP("smtp.163.com",25)
s.login(msg_from, passwd)
s.sendmail(msg_from, msg_to, msg.as_string())
# print "发送成功"
#except s.SMTPException,e:
# print "发送失败"
#finally:
s.quit()