#!/usr/bin/python
# coding: utf-8
import smtplib
from email.mime.text import MIMEText
from email.header import Header

sender = 'xxxxxxxx@163.com'
receiver = '874247458@qq.com'
subject = 'python 调试'
smtpserver = 'smtp.163.com'
username = 'xxxxxxxx@163.com'   #发送邮件的邮箱
password = '*************'      #发送邮件的邮箱密码

msg = MIMEText('你好')  # 中文需参数‘utf-8',单字节字符不需要
msg['Subject'] = Header(subject, 'utf-8')
msg["from"] = sender
msg["to"] = receiver

smtp = smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.login(username, password)
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()
print '邮件发送成功!'