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

python发送email

2015-11-26 16:34 543 查看
#!/usr/bin/env python
#send_simple_email_by_account.py @2014-08-18
#author: orangleliu

import smtplib
from email.mime.text import MIMEText

SMTPserver = 'smtp.qq.com'
sender = '12345678@qq.com'
destination = 'typ123456@qq.com'
password = "impasswd"

message = 'I send a message by Python. hello'
msg = MIMEText(message)

msg['Subject'] = 'Test Email by Python'
msg['From'] = sender
msg['To'] = destination

mailserver = smtplib.SMTP(SMTPserver, 25)
mailserver.login(sender, password)
mailserver.sendmail(sender, [destination], msg.as_string())
mailserver.quit()
print 'send email success'


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