#!/usr/bin/env python
#_*_ coding: utf-8 _*_
import smtplib
from email.mime.text import MIMEText
from email.header import Header
sender = 'xxxxxxx@xxxxxx.com' #发件人
receiver = ['xxxxxxx@qq.com'] #收件人
subject = 'python email test' #定义主题
smtpserver = 'mail.urundp.com' #第三方smtp服务器
username = 'xxxxx@xxxxxx.com' #用户名
password = 'xxxxxxxx' #密码
msg = MIMEText('Python mail test','plain','utf-8') #格式:邮件内容/格式/编码
msg['Subject'] = Header(subject, 'utf-8')
try:
smtp = smtplib.SMTP()
smtp.connect('mail.urundp.com')
smtp.ehlo()
smtp.starttls()
smtp.login(username, password)
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()
print '邮件发送成功'
except smtplib.SMTPException,ex:
print '邮件发送失败',ex