GithubHelp home page GithubHelp logo

Comments (15)

selwin avatar selwin commented on June 16, 2024

We could perhaps introduce a kwarg "split_recipients" (other naming suggestions welcome) to "mail.send".

from django-post_office.

ivans083 avatar ivans083 commented on June 16, 2024

it's quite annoying that it sends multiple emails rather than one to the recipient_list as expected. Adding an optional argument should be ok, but definitely the default behavior should be sending just one email. This is important as it also doesn't support adding people in +cc.

from django-post_office.

selwin avatar selwin commented on June 16, 2024

I'm open to adding this feature. Any ideas on how to implement this?

Sent from my phone

On Jan 29, 2014, at 7:01 PM, ivans083 [email protected] wrote:

it's quite annoying that it sends multiple emails rather than one to the recipient_list as expected. Adding an optional argument should be ok, but definitely the default behavior should be sending just one email. This is important as it also doesn't support adding people in +cc.


Reply to this email directly or view it on GitHub.

from django-post_office.

ivans083 avatar ivans083 commented on June 16, 2024

In mail.py:
emails = [create(sender, recipient, subject, message, html_message, context,
scheduled_time, headers, priority, commit)
for recipient in recipients]

create should take the list of recipients rather than iterating recipients

from django-post_office.

evgenyfadeev avatar evgenyfadeev commented on June 16, 2024

Can this be implemented via user groups as well as individual users? Ideally when mails are sent the "to" field would not disclose other recipients.

Maybe the Email model could be related as M2M to users and groups.

from django-post_office.

selwin avatar selwin commented on June 16, 2024

I've been thinking about this in the past few days. We should also add cc, bcc fields that allows multiple email addresses.

So this would look like:

mail.send(
    to=[user_1],
    cc=[user_2],
    bcc=[user3],
    # Other arguments
)

I'll have to find the time to implement this though. I have other features I want to prioritize over this so pull requests are welcome :)

from django-post_office.

dnelson86 avatar dnelson86 commented on June 16, 2024

Hi,

I hacked this in since I need it. Below are the changes to mail.py and models.py (no DB changes needed with this approach):

In mail.py send():

    emails = [create(sender, ",".join(recipients), subject, message, html_message,
                     context, scheduled_time, headers, template, priority,
                     render_on_delivery, commit=commit)]
#    emails = [create(sender, recipient, subject, message, html_message,
#                     context, scheduled_time, headers, template, priority,
#                     render_on_delivery, commit=commit)
#              for recipient in recipients]

In models.py Email:

    to = models.CharField(max_length=254)
    #to = models.EmailField(max_length=254)

In models.py Email->email_message():

            msg = EmailMessage(subject, message, self.from_email,
                               self.to.split(","), connection=connection,
                               headers=self.headers)
#            msg = EmailMessage(subject, message, self.from_email,
#                               [self.to], connection=connection,
#                               headers=self.headers)

from django-post_office.

evgenyfadeev avatar evgenyfadeev commented on June 16, 2024

Hello,

Sorry if this is not in line with your thoughts, but I thought it might be
good to still have one receiver per message and at the same time
be able to message multiple users - either by list of emails,
list of AuthUser objects or members of a specific group.

Also - after trying the app I've found that there is a record in the
database per email sent. This in nice, but not practical when you
send thousands of emails. One per campaign might be nicer to have,
or perhaps have a separate entry for "Campaigns"

Thanks for working on this app.

On Tue, May 6, 2014 at 6:40 PM, Dylan Nelson [email protected]:

Hi,

I hacked this in since I need it. Below are the changes to mail.py and
models.py (no DB changes needed with this approach):

In mail.py send():

emails = [create(sender, ",".join(recipients), subject, message, html_message,
                 context, scheduled_time, headers, template, priority,
                 render_on_delivery, commit=commit)]

emails = [create(sender, recipient, subject, message, html_message,

context, scheduled_time, headers, template, priority,

render_on_delivery, commit=commit)

for recipient in recipients]

In models.py Email:

to = models.CharField(max_length=254)
#to = models.EmailField(max_length=254)

In models.py Email->email_message():

        msg = EmailMessage(subject, message, self.from_email,
                           self.to.split(","), connection=connection,
                           headers=self.headers)

msg = EmailMessage(subject, message, self.from_email,

[self.to], connection=connection,

headers=self.headers)


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-42362949
.

Askbot
Valparaiso, Chile
skype: evgeny-fadeev

from django-post_office.

selwin avatar selwin commented on June 16, 2024

@evgenyfadeev you should check one the render_on_delivery option introduced in 0.8.0 and log_level later in the series. It allows you to store content only once in EmailTemplate, I built that with newsletter/campaign type usage in mind.

Content is only stored once in template, yet you still get the benefit of using context variables. All that plus the parallel processing and more flexible logging options allow us to efficiently send millions on email :).

You can do:

for user in User.objects.all():
    mail.send(user.email, template=template,
              render_on_delivery=True, context={'name': user.username},
              log_level=1)

from django-post_office.

stefan-mihaila avatar stefan-mihaila commented on June 16, 2024

@selwin I want to implement cc and bcc fields and send one email to multiple recipients. Do you think it would be better to add cc and bcc fields to the Email model and store the list of recipients as a comma separated string or add distinct models (like ToRecipient, CcRecipient and BccRecipient) and store each recipient address as a separate entry using a ForeignKey to the Email?

I will make a pull request when I'm done.

from django-post_office.

selwin avatar selwin commented on June 16, 2024

@stefan-mihaila please implement cc and bcc fields as comma separated email addresses. Thanks for working on this :)

from django-post_office.

selwin avatar selwin commented on June 16, 2024

FYI, Django has a CommaSeparatedIntegerField implemented in core so if you could just make something similar for email addresses it would be great

from django-post_office.

stefan-mihaila avatar stefan-mihaila commented on June 16, 2024

Thanks to you for contributing! I'll work on it this weekend.

from django-post_office.

stefan-mihaila avatar stefan-mihaila commented on June 16, 2024

I created a pull request for this issue.

from django-post_office.

selwin avatar selwin commented on June 16, 2024

Fixed in #63

from django-post_office.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.