Skip to content

Checking duplicate email address specified into personalizations as case insensitive #436

@pranc1ngpegasus

Description

@pranc1ngpegasus

Issue Summary

SendGrid says:

All of the recipients in a single personalization object (either in the to, cc, or bcc fields) will see the same email, as defined by the data in that personalization, as such we do not allow duplicate emails between these 3 arrays in a single personalization.

ref: https://sendgrid.com/docs/for-developers/sending-email/personalizations/

And https://github.com/sendgrid/sendgrid-csharp implements case insensitive comparison method.
https://github.com/sendgrid/sendgrid-csharp/blob/23e4f6425c2d8546f1c8ca84bc2c93e5c5f9c1df/src/SendGrid/Helpers/Mail/Model/EmailAddress.cs#L91

I want to get implemented method that checking duplicate email address specified into personalizations as case insensitive.

Steps to Reproduce

  1. specify duplicate email address to "to addresses".
  2. request to send email
  3. get 400 error that says "Each unique email address in the personalizations array should only be included once. You have included [email address] more than once."

Exception/Log

I have checked how SendGrid behaves to duplicated email addresses.
Then, SendGrid returned 2 errors for following request body.

Request Body

{
  "personalizations": [
    {
      "to": [
        {
          "email": "test@example.com"
        },
        {
          "email": "TEST@example.com"
        }
      ],
      "cc": [
        {
          "email": "test@foobar.com"
        },
        {
          "email": "TEST@foobar.com"
        }
      ],
      "subject": "Hello, World!"
    }
  ],
  "from": {
    "email": "test@sender.com"
  },
  "content": [
    {
      "type": "text/plain",
      "value": "Hello, World!"
    }
  ]
}

Returned error

{
  "errors": [
    {
      "message": "Each email address in the personalization block should be unique between to, cc, and bcc. We found the first duplicate instance of [test@example.com] in the personalizations.0.to field.",
      "field": "personalizations.0",
      "help": "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.recipient-errors"
    },
    {
      "message": "Each email address in the personalization block should be unique between to, cc, and bcc. We found the first duplicate instance of [test@foobar.com] in the personalizations.0.cc field.",
      "field": "personalizations.0",
      "help": "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.recipient-errors"
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions