首页 > 编程语言 > 详细

python 2.6.6 smtplib 发送邮件

时间:2017-09-07 22:43:44      阅读:246      评论:0      收藏:0      [点我收藏+]

#!/usr/bin/python

import smtplib
import string

HOST = "mail.merit-link.com"
SUBJECT = "Test email from Python"
TO = "yaosx@merit-link.com"
FROM = "yaosx@merit-link.com"
text = "Python rules them all!"
BODY = string.join((
    "From: %s" %FROM,
    "TO: %s" %TO,
    "Subject: %s" %SUBJECT,
    "",
    text
    ),"\r\n")

server = smtplib.SMTP()
server.connect(HOST,"25")
server.login("yaosx","mypasswd")    #注意此处是登录的用户名和密码
server.sendmail(FROM,[TO],BODY)
server.quit()




本文出自 “春去春来” 博客,请务必保留此出处http://yaoshixian.blog.51cto.com/754237/1963419

python 2.6.6 smtplib 发送邮件

原文:http://yaoshixian.blog.51cto.com/754237/1963419

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!