Sendgrid-python: Duplicate emails in the Personalization object are not allowed, make this obvious

Created on 23 Apr 2019  路  6Comments  路  Source: sendgrid/sendgrid-python

Issue Summary

When you add a recipient email address again as a BCC address, sending fails with:

BadRequestsError: HTTP Error 400: Bad Request

Steps to Reproduce

  1. Add the same email address as a recipient and BCC.

Technical details:

sendgrid Version: 5.4.1
Python Version: 3.6

See this issue: https://github.com/sendgrid/sendgrid-python/issues/779

medium help wanted community enhancement

All 6 comments

Thanks for taking the time to post this issue @tomwwagstaff-product!

It is expected behavior for the Twilio SendGrid API to reject emails that have duplicate emails within the Personalization object.

We should provide a meaningful error when someone attempts to add duplicate emails.

Going to look into this one

Note that in C# we now de-dupe the recipients rather than error: https://github.com/sendgrid/sendgrid-csharp/pull/991

So I think I have a solution for this right now. Do we want to de-dupe on a Mail object's construction, or do we want to de-dup emails whenever possible on the Personalization object, including on setters? Currently, I'm doing it on a Mail object's construction (more specifically, in Personalization.add_email), and whenever Personalization.add_to, Personalization.add_bcc, or Personalization.add_cc are called. Essentially, I just check if the email already exists somewhere in _tos, _bccs or _ccs, and if so, we don't add the email.

I think de-dupe whenever possible, but not de-dupe across to/cc/bcc; dupes are allowed between them.

I am sending login details to users with personalization in bulk (say 500 users at one time). in my application 2 users can have same email.
When I send emails , if 2 users have same email, only one is delivered.
Is there a setting to ignore duplicate emails, as with personalization contents may be different.

Was this page helpful?
0 / 5 - 0 ratings