Sending Bulk email in Django

跟風遠走 提交于 2020-01-23 11:58:45

问题


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.

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.


回答1:


You can use django's default sending multiple email system. From here: https://docs.djangoproject.com/en/dev/topics/email/#sending-multiple-emails

You can try like this:

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()

For bulk email reference, you can check this so answer: How does one send an email to 10,000 users in Django?

Edit

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.

By the way, for mass email handling, django has send_mass_mail() method.



来源:https://stackoverflow.com/questions/24474316/sending-bulk-email-in-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!