9

Tried using personalization with substitution like %body%. However, I get an error saying Substitutions are limited to 10000 bytes per personalization. Basically the whole body would differ recipient to recipient.

Is there another efficient way to send distinct mails to different recipients?

Sending one mail per request would be very slow.

PLEASE NOTE: Template isn't an option as the mails are created based on user's current activity.

3

2 Answers 2

1

I think that what you are asking is simply not possible under Sendgrid's API. They are already providing you with an option to include variables (10000 bytes) to do so.

Proposal #1: You could use a Queue (ApacheMQ or Amazon SQS) system with a few workers to process the sending of emails. The queue is to prevent any email of not being delivered, and the workers are for letting you send more than one email at a time (2 workers, 2 emails being sent in parallel).

Proposal #2: Have a simple cronjob that runs every 5 minutes (you will need to calculate that according to how many emails you have to send and which is the acceptable delay under which to send the emails) and gets 100 customers to who to send emails, based on a column of a database that tells you whether you have sent the email or not, so you avoid sending more than one email to the same customer.

Ideally, I will stick with the 1st proposal, but it could require more work. You could start with #2 and then work on #1 bit by bit.

Hope it helps!

2
  • I am currently using the #2 way. Sending mails immediately one after the other. I don't know if there is a limit on number of API calls to Sendgrid. Commented Jul 21, 2016 at 9:34
  • You will need to check that, but I believe that they are more or less OK, as long as you are sending emails to people who agreed that you send them emails, and since you pay per email sent, Sendgrid should be fine with it.
    – xarlymg89
    Commented Jul 25, 2016 at 15:09
0

I was running in to the 10000 bytes limit as well. In my case it was an edge case so for these calls I added a fallback using regular SMTP sending.

  1. Call SendGrid's API and fetch the HTML for the template
  2. Iterate the substitutions and replace subject and body
  3. Iterate the recipients and do a SMTP-call per recipient

Not an option for everybody but it was very easy to get in place.

1
  • I too did something like this, manually replacing elements in html and sending individual emails. However, this process is slow. Would have been great if there was a way in sendgrid to send every mail in one call. Saves time and cpu usage. Commented Apr 16, 2017 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.