sklarsa / django-sendgrid-v5

An implementation of Django's EmailBackend compatible with sendgrid-python v5+
MIT License
323 stars 54 forks source link

sending emails to multiple recipients not working #40

Closed AdrienLemaire closed 6 years ago

AdrienLemaire commented 6 years ago

I just realize that whenever we send emails to a mailing list as follow:

        # settings.py
        MANAGERS = ['1@example.com', '2@example.com']

        # email.py
        from django.core.mail import send_mail
        from django.conf import settings

        result_managers = send_mail(manager_subject, message,
                                    from_email, settings.MANAGERS,
                                    html_message=manager_message,
                                    fail_silently=False)

only one of the recipients in the list will receive the email. By checking the last 3 days of activity on sendgrid, I see that 3/8th of mails went to 1@example.com and 5/8th went to 2@example.com. Assuming an email is picked randomly from the list :/

This is unfortunately a critical issue. Not sure if it's related to this project SendgridBackend or an issue with the upstream sendgrid service.

Any idea why this bug occurs and if it can be fixed quickly @sklarsa ?

sklarsa commented 6 years ago

That seems very strange. At this level, we add multiple recipients to the Personalization object and pass that along to sendgrid (https://github.com/sklarsa/django-sendgrid-v5/blob/master/sendgrid_backend/mail.py#L91), which matches what they have in their API documentation (https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html).

I would take a look at https://github.com/sendgrid/sendgrid-python to see if there are any similar issues. I can run some tests later today to see if I can repro the behavior.

AdrienLemaire commented 6 years ago

Would really appreciate that. Our temporary solution is to loop through the recipients of the list and send emails individually (a bit worried that it'll eat our monthly plan limit).

On Wed, Oct 3, 2018 at 8:02 PM Steven Sklar notifications@github.com wrote:

That seems very strange. At this level, we add multiple recipients to the Personalization object and pass that along to sendgrid ( https://github.com/sklarsa/django-sendgrid-v5/blob/master/sendgrid_backend/mail.py#L91), which matches what they have in their API documentation ( https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html).

I would take a look at https://github.com/sendgrid/sendgrid-python to see if there are any similar issues. I can run some tests later today to see if I can repro the behavior.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sklarsa/django-sendgrid-v5/issues/40#issuecomment-426596094, or mute the thread https://github.com/notifications/unsubscribe-auth/AAP7d4sUbgC7h4wmabZWtP4UJ1TqbznWks5uhJlhgaJpZM4XFgA5 .

sklarsa commented 6 years ago

I just tested this line... send_mail("Test","Test Content","sender@sender.com",["email1@corp.com","email2@corp.com"],fail_silently=False) and I received the message in both inboxes. This is running sendgrid_backend==0.6.893 and sendgrid==5.0.0

Perhaps it is something with the MANAGERS value in settings.py?

Sorry I can't help any further. I'm going to close this issue since I can't repro. I suggest reaching out to sendgrid for further assistance.