sendgrid-python icon indicating copy to clipboard operation
sendgrid-python copied to clipboard

Duplicate emails in the Personalization object are not allowed, make this obvious

Open tomwwagstaff-product opened this issue 7 years ago • 8 comments

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

tomwwagstaff-product avatar Apr 23 '19 14:04 tomwwagstaff-product

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.

thinkingserious avatar Apr 24 '19 20:04 thinkingserious

Going to look into this one

DougCal avatar Jul 06 '20 14:07 DougCal

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

childish-sambino avatar Jul 06 '20 14:07 childish-sambino

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.

DougCal avatar Jul 10 '20 14:07 DougCal

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

childish-sambino avatar Jul 10 '20 21:07 childish-sambino

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.

kamaldua65 avatar Mar 17 '21 04:03 kamaldua65

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.

Same issue. Did you get any solution?

mohankr123 avatar Feb 18 '22 11:02 mohankr123

Thanks for submitting a GitHub issue! We are very sorry that you are running into this problem. In order to better serve you, as this does not present itself as a library specific issue, we would like to ask that you reach out to our support team at support.sendgrid.com.

childish-sambino avatar Feb 18 '22 15:02 childish-sambino