I'm using sendgrid java web api client from their website to send mail through the web api gateway. My problem is that i can only send one message per request and i usually have need to send 1000-1500 messages at a time which are all different in content, so I just send them in a loop. However, this makes 1000-1500 api request which is very slow.
Is it possible to send multiple individual different emails in one request?
This is a bit of a workaround, but you could batch different emails together into one request by using the substitution
property of the X-SMTPAPI header. In your email body, include only the substitution token, e.g. %content%
. Then pass your actual content in the header, e.g.
{
"to": [
"[email protected]",
"[email protected]"
],
"sub": {
"%content%": [
"Here is the content for the email to john.doe",
"And this is some different content for jane.doe"
]
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With