`
san_yun
  • 浏览: 2654992 次
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

django + postfix 搭建邮件服务

 
阅读更多

email 配置:

 

SERVER_EMAIL = "server@%s" % HOST
EMAIL_HOST = "localhost"
EMAIL_PORT = 25
EMAIL_HOST_USER = "server@duitang.com"
DEFAULT_FROM_EMAIL = u'堆糖网  <server@duitang.com>'

 

25对应的 /usr/libexec/postfix/master

 

def sendEmail2(addresses, title, content, from_email=u"网站台 <no-reply@zhangyutai.com>"):
    "发送邮件方法"
    if type(addresses) in (types.StringType, types.UnicodeType):
        addresses = (addresses,)
    addr_list = []
    for addr in addresses:
        if addr not in addr_list:
            addr_list.append(addr)
    try:
        msg = EmailMessage(title, content, from_email or DEFAULT_FROM_EMAIL, addr_list)
        msg.content_subtype = "html"
        msg.send()
        return True
    except Exception, e:
        return False

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics