在Django中发送批量电子邮件 [英] Sending Bulk email in Django
问题描述
我必须使用django发送批量电子邮件,该电子邮件模板将被自定义,并且该模板中的某些数据将来自db.我使用django通知,但只能将电子邮件发送给注册用户.我必须向未注册的用户发送电子邮件.将有五个电子邮件模板,用户可以选择其中之一,并且必须发送电子邮件.
I have to send bulk email in django, the email template will be will be customized and the some data in the template will be coming from db. i twas using django notification but it can only send email to the registered users. I have to send emails to the non-registered users. there will be five email template the user can select any one and the email has to be sent.
例如向未注册用户组的活动邀请.用户将输入电子邮件ID,并将进行批量发送.我可以使用哪个django软件包来实现相同的目标.
For ex. An invitation to the event to the group of non-registered users. user will enter email ids, and will do a bulk send. which django package can i use to achieve the same.
推荐答案
您可以使用django的默认发送多个电子邮件系统.从这里开始: https://docs.djangoproject.com/zh/dev/topics/email/#sending-multiple-emails
You can use django's default sending multiple email system. From here: https://docs.djangoproject.com/en/dev/topics/email/#sending-multiple-emails
您可以尝试这样:
from django.core import mail
connection = mail.get_connection()
connection.open()
reciever_list= ['aa@bb.cc', 'dd@ee.ff'] #extend this list according to your requirement
email1 = mail.EmailMessage('Hello', 'Body goes here', 'from@example.com',
reciever_list, connection=connection)
email1.send()
connection.close()
For bulk email reference, you can check this so answer: How does one send an email to 10,000 users in Django?
通过此stackoverflow answer ,您可以发送带有模板的电子邮件.如果使用django 1.7,则可以将html_message添加为send_mail()
的性能参数.详细信息此处.
From this stackoverflow answer, you can send emails with template. If you use django 1.7, html_message can be added as perameter of send_mail()
. Details here.
顺便说一下,对于大量电子邮件处理,django具有 send_mass_mail()方法.
By the way, for mass email handling, django has send_mass_mail() method.
这篇关于在Django中发送批量电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!