您的位置:首页 > 编程语言 > Python开发

python smtp邮件转发

2014-10-10 13:32 274 查看
#!/usr/bin/python

#decoding=utf-8

import sys

import smtplib

reload(sys)

sys.setdefaultencoding('utf-8')

print 'Content-Type: text/html;charset=utf-8\r\n'

from email.mime.text import MIMEText

sender="****"//发件人的邮箱

receivers="****"//收件人的邮箱

login_user="user"//账户

login_passwd="passwd"//密码

smtp_connect="smtp.qq.com"//连接,如果是163邮箱,则为163.com

msg = MIMEText('mail_content')

msg['From'] = sender

msg['To'] = receivers

msg['Subject'] = 'mail_test'

smtp = smtplib.SMTP()

smtp.connect(smtp_connect)

smtp.login(login_user, login_passwd)

smtp.sendmail(sender, receivers, msg.as_string())

smtp.quit()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: