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

smtp 发邮件

2015-06-01 10:48 615 查看
”’python

coding=utf-8

import smtplib

from email.mime.text import MIMEText

from email.mime.image import MIMEImage

from email.mime.multipart import MIMEMultipart

sender = ‘xxxxxxx@qq.com’

receivers = [‘2313248751@qq.com’]

msg=MIMEMultipart()

msg[“From”]=”power@power.com”

msg[“To”]=”you@yourself.com”

msg[“Subject”]=”Test smtp by s2”

text=MIMEText(“this is text content”)

msg.attach(text)

try:

smtp=smtplib.SMTP()

smtp.connect(“smtp.qq.com”)

smtp.login(‘xxxxxxx@qq.com’,”xxxx”)

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

print “Successfully sent email”

except :

print “Error: unable to send email”

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