sendgrid
sendgrid copied to clipboard
Use pretty JSON to reduce risk of going over 1k character per line limit
According to [Sendgrid's SMTP API documentation]( https://sendgrid.com/docs/API_Reference/SMTP_API/using_the_smtp_api.html
-Requirements-and-Limitations), all lines in a header must be under
1,000 characters. By using JSON.pretty_generate
, arrays (e.g. multiple recipients and substitutions) will be wrapped, reducing the likelihood of exceeding this limit, with the exception being if some element in an array is itself over 1,000 characters long.
I have now found out that ActionMailer takes care of wrapping lines, which must be why you had the gsub
to add the spaces. Still, using pretty_generate
could make that a bit clearer.