我必须在 django 中发送批量电子邮件,电子邮件模板将被定制,模板中的一些数据将来自数据库。我正在使用 django notification,但它只能向注册用户发送电子邮件。我必须向非注册用户发送电子邮件。将有五个电子邮件模板,用户可以选择任何一个并且必须发送电子邮件。
对于前。向非注册用户组发出参加活动的邀请。用户将输入电子邮件 ID,然后进行批量发送。我可以使用哪个 django 包来实现相同的目的。
您可以使用 django 默认的发送多封电子邮件系统。从这里:https://docs.djangoproject.com/en/dev/topics/email/#sending-multiple-emails https://docs.djangoproject.com/en/dev/topics/email/#sending-multiple-emails
你可以这样尝试:
from django.core import mail
connection = mail.get_connection()
connection.open()
reciever_list= ['[email protected] /cdn-cgi/l/email-protection', '[email protected] /cdn-cgi/l/email-protection'] #extend this list according to your requirement
email1 = mail.EmailMessage('Hello', 'Body goes here', '[email protected] /cdn-cgi/l/email-protection',
reciever_list, connection=connection)
email1.send()
connection.close()
对于批量电子邮件参考,您可以检查此答案:如何在 Django 中向 10,000 个用户发送电子邮件? https://stackoverflow.com/questions/8659131/how-does-one-send-an-email-to-10-000-users-in-django
Edit
从这个堆栈溢出answer https://stackoverflow.com/questions/2809547/creating-email-templates-with-django,您可以使用模板发送电子邮件。如果您使用 django 1.7,则可以添加 html_message 作为参数send_mail()
。细节here https://docs.djangoproject.com/en/dev/topics/email/#send-mail.
顺便说一句,对于批量电子邮件处理,django 有发送群发邮件() https://docs.djangoproject.com/en/1.6/topics/email/#send-mass-mail方法。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)