sendgrid_toolkit icon indicating copy to clipboard operation
sendgrid_toolkit copied to clipboard

Mail#send_mail cannot handle a large multiline x-smtpapi header

Open RUN-CMD opened this issue 13 years ago • 5 comments

SendgridToolkit::AbstractSendgridClient#api_post calls HTTParty.post using the options key "query" rather than "body". When using the key "query", HTTParty appends the urlencoded options to the URI.

With a large x-smtpapi header (eg. sending to hundreds of recipients) via Mail#send_mail, this causes SendGrid's servers to return a "414 Request-URI Too Large" (they also incorrectly return the error as text/html rather than just headers :/ ).

Since SendgridToolkit sends all requests as POST, I think it'd be safe to always send the request parameters as the request body rather than in the query string.

RUN-CMD avatar Aug 14 '12 21:08 RUN-CMD

Same problem with large HTML messages. Using :body instead of :query does the trick. I don't have time to do a PR (I'm sorry). Great project btw, keep up the good work guys.

did avatar Aug 20 '12 13:08 did

@RUN-CMD @did Thanks for the reports, guys. I'll try to get to it this week. I just need to manually verify first that it won't break anything, since Sendgrid responses are stubbed out in all but the web-connect tests in our test suite.

freerobby avatar Aug 20 '12 13:08 freerobby

I just monkey patched :query to be :body, and it worked great. My problem was that my email body was "too big". I also personally would side with switching :query to :body for two reasons: 1.) It provides backwards compatibility. 2.) It's a post. Posts are supposed to contain data.

I would have created a PR for you, but I see that smoak's was never responded to, and that was 8 months ago.

natematykiewicz avatar Feb 28 '14 22:02 natematykiewicz

Sorry, I've had a hard time keeping up here. I will take a look at the PRs on Monday. I would also welcome taking on another maintainer if someone is interested.

On Fri, Feb 28, 2014 at 5:53 PM, nmaty52589 [email protected]:

I just monkey patched :query to be :body, and it worked great. My problem was that my email body was "too big". I also personally would side with switching :query to :body for two reasons: 1.) It provides backwards compatibility. 2.) It's a post. Posts are supposed to contain data.

I would have created a PR for you, but I see that smoak's was never responded to, and that was 8 months ago.

Reply to this email directly or view it on GitHubhttps://github.com/freerobby/sendgrid_toolkit/issues/13#issuecomment-36403090 .

freerobby avatar Feb 28 '14 23:02 freerobby

I ran into this issue as well. I'm going to try monkey patching it by changing :query to :body and see if everything still works as expected.

Update: Everything is working as expected when I changed :query to :body

djiang avatar Jun 12 '14 23:06 djiang