Sendgrid: send several different emails with one request

I am using sendgrid java web api client from my website to send mail through the api web interface. My problem is that I can only send one message for each request, and usually I need to send 1000-1500 messages at a time, which vary in content, so I just send them in a loop. However, this makes a request for 1000-1500 api, which is very slow.

Is it possible to send several separate letters for one request?

+4
source share
2 answers

This is a bit of a workaround, but you can combine different emails into a single request using the X-SMTPAPI header substitutionproperty . In your body of the message, specify only the replacement token, for example. . Then pass your actual content in the header, for example.%content%

{
  "to": [
    "john.doe@gmail.com",
    "jane.doe@hotmail.com"
  ],
  "sub": {
    "%content%": [
      "Here is the content for the email to john.doe",
      "And this is some different content for jane.doe"
    ]
  }
}
+2
source

Yes this:

https://sendgrid.com/docs/Integrate/Code_Examples/java.html

You can simply add multiple emails to your email, for example:

email.addTo("anemail@example.com")

However, you want to do this by adding a few BCCs instead, so that you do not give out all email addresses.

email.addBcc("anemail@example.com")
0
source

Source: https://habr.com/ru/post/1626176/


All Articles