为了以后使用方便,记录一下。
在工程settings.py首行添加内容"EMAIL_USE_TLS = True"

v1.13更新:1.增加产品讨论功能(ProductMsg备注字段)2.修正页面中的js错误数处。3.删除后的拍卖产品在回收站中统一管理。4.版面图标的DIY..自己更换,表格颜色自由调配。5.无限分类结构优化。6.产品说明支持HTML.7.网页界面优化.8.修正产品上下跳转的条数错误。9.完善邮件群发功能,可选择发送给不同类型的商城用户。10.修正拍卖信息中错误的交易完成Bug。11.去掉搜索用
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










