- 2010/06/02 08:50
- 66 次阅读
-
Python
项目里一个模块,重新封装了python的smtplib和django的template
主要功能:
支持多用户接受
支持模板
良好的处理了中文问题
代码如下:
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
#
__author__="Fred"
__date__ ="$2010-5-31 17:15:35$"
import smtplib, base64
from django.template import loader, Context
CHARSET = 'utf-8'
FROM_ADD = 'xxxxxx@163.com'
SMTP_SERVER = 'smtp.163.com'
SMTP_USER = 'xxxxx'
SMTP_PASS = 'xxxxx'
class SendMail:
u'''
邮件发送模块,此模块运行使用django模块来发送邮件
参数介绍(*必填):
subject *邮件主题
template *邮件模板位置
context *邮件模板上下文
to_addr *目的地址,允许发给多人,格式为['test@examp.com','test2@example',......]
smtp_server 发件服务器地址
smtp_server_port 发件服务器端口号
from_addr 发信地址
from_addr_name 发信人名称
user 发件箱登录用户名
pass 发件箱登录密码
e.g:
from ureg.helper import SendMail
mail = SendMail('test','email/register.html',{'tmp
......
django
python
mail
More
Recent Comments