您好,欢迎访问一九零五行业门户网

如何在Django中调用exchange发送HTML邮件

为了以后使用方便,记录一下。
在工程settings.py首行添加内容email_use_tls = true
2.脚本内容
script file: usermail.py #!/usr/bin/env python # -*- coding: utf-8 -*- from django.core.mail import emailmultialternatives,get_connection from django.template.loader import render_to_string from django.conf import settings import sys reload(sys) sys.setdefaultencoding('utf-8') def usermail(tousers,obj,html_content): conn = get_connection() conn.username = 'ops' conn.password = '123456' conn.host = 'exchange.test.com' try: conn.open() email_host_user = 'ops@test.com' subject, from_email, to = obj, email_host_user, tousers msg = emailmultialternatives(subject, html_content, from_email, to) msg.attach_alternative(html_content, "text/html") conn.send_messages([msg,]) conn.close() except exception,e: print e
以上就是如何在django中调用exchange发送html邮件的详细内容。
其它类似信息

推荐信息