sendgrid-ruby: SendGrid fails when a name contains comma character

Issue Summary

When names include a comma character “,” the email is dropped by SendGrid due to reason “Invalid”, because it interprets the wrong email address. In the Activity view, SendGrid appears to have tried to send to part of the name field instead of the email field, indicating the the “comma” was used even though it is in part of a string.

Steps to Reproduce

Here is the repro call to SendGrid::API:

    params = {
      "template_id" => "88dd23ff-f322-40a4-b646-1144c43340a8",
      "subject" => "Forgot your password?",
      "personalizations" =>
        [
          {
            "to" =>
              [
                {
                  "email" => "smart+test@figma.com",
                  "name" => "Figma, Inc."
                }
              ],
            "substitutions" =>
              {
                "{{URL_ESCAPED_VALIDATION_TOKEN}}" => "***REDACTED***",
                "{{URL}}" => "https://www.figma.com",
                "{{SUPPORT_EMAIL}}" => "smart+test@figma.com",
                "{{UNSUBSCRIBE_TOKEN}}" => "***REDACTED***"
              }
          }
        ],
      "tracking_settings" => {
        "click_tracking" => {"enable" => false},
        "open_tracking" => {"enable" => false}
      },
      "content" =>
        [
          {"type" => "text/html", "value" => " "}
        ],
      "from" =>
        {
          "email" => "support@email.figma.com",
          "name" => "Figma"
        }
    }

    response = sendgrid.client.mail._('send').post(request_body: params)
    puts response.to_json

The result is a 202, but the email does not get sent because it is rejected due to “Invalid”, and the reported email address it tried sending to is “Figma” instead of “smart+test@figma.com”.

Here is the result from sendgrid.client.suppression.invalid_emails.get

[{\"created\":1468461165,\"email\":\"figma\",\"reason\":\"Invalid address\"}]

Are there undocumented rules for names? Are we supposed to encode them in some way or strip special characters? Why doesn’t your platform do this for us? Why doesn’t your platform reject the request?

Technical details:

  • sendgrid-ruby Version: sendgrid-ruby 3.0.4
  • Ruby Version: 2.3.1

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 21 (10 by maintainers)

Most upvoted comments

I realize I am digging this up from the grave but we also ran into this issue as well. Its great that the documentation was updated with these caveats, but how does that really help? This should be an error condition sent back to the client so that anyone interfacing with the API knows that something is amiss. It is unexpected behavior that SendGrid would simply drop the email and respond to the API client as if everything was fine, that is the real bug.

Much appreciated @thinkingserious !

To be clear, no error is returned by the API. I will replace those character with spaces. Thanks for the help! ❤️

On Monday, July 18, 2016, Elmer Thomas notifications@github.com wrote:

@thesmart https://github.com/thesmart,

Commas and semicolons seem to be the only ones currently.

As a workaround, I’d do a try/catch and look for instances of that error. If the error occurs, I’d replace that character with an appropriate one and re-send.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-ruby/issues/77#issuecomment-233352326, or mute the thread https://github.com/notifications/unsubscribe-auth/AARJLZP25KslHqv562ncGyHeCzhlbDRZks5qW5M-gaJpZM4JMtKk .