-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send a Single Email to Multiple Recipients #301
Comments
This would pose quite difficult to build a one-size-fits-all method. If you look at my Yii2 SendGrid extension, it does this. In my example, I use Yii's ActiveRecord batch method to grab all the users from the database in batches of 500. The personalization object is filled with those 500 people. So if you had 2,000 users, it would only make 4 calls to the SendGrid API. 10,000 users, 20 calls. Very efficient 👍 There would almost have to be a helper that you fed ALL of the recipients into, that then splits them in batches (ie: 500 per loop). The problem you will run into, is if you had say 50,000 users in the database. What type of load would that put on the system? Loading the helper with 50k recipients to then process. I am not sure at what point you would reach memory errors and such. You don't really want one huge gigantic array of 50k people. Yii uses ActiveRecord and efficiently can load batches. I am not really concerned if there was 50k users in the system, I think AR would handle it just fine. Honestly, the best way is a cron job and to load all your recipients in a db table. Every few minutes, run and grab a few thousand, and process them (filling SendGrid personalization object with 500-1,000). You queue an email to 50k people, every minute the cron runs and grabs 5k (which makes 5-10 API calls). It would take about 10 minutes to mail to 50k people. - This would require a separate SendGrid PHP Queue library to be developed. I guess the main question, is what is the point of this issue? It is easy to fill the SG personalization object with 500-1,000 people and kick off the email.. It is another story to handle 50k people and split it into micro-batches... |
Hi @WadeShuler, We want to add some helpers to help make the most common use cases simpler. Please see the overarching project "Mail Helper Enhancement (v3 mail/send)." Here is how we implemented this in C#. The first step would be to propose the function signature. With regards to batching, I love the idea of including batching as part of the helper, perhaps that's a parameter passed to this function. With Best Regards, Elmer |
Hi, just chiming in from the previous issue #269 and the Personalizations object mentioned there. One of the features I'd really like from a new API is to just completely separate the additional To-email inputs from the content of the email itself. In my example I use a number of substitution tags to fill in the email template, but these are going to be the exact same for every receiver. AFAIK, both the Personalizations object and the previous SMTP API required duplicating all of these tags in a big array for every email sent which was just not necessary. |
Thanks for taking the time to provide some feedback @thedailynathan! Please stay tuned for a proposal on how we will implement (to be posted here) as I'm sure your feedback will be valuable. With Best Regards, Elmer |
@thedailynathan - Substitution tags are supposed to be unique to that personalization object. Example: If your replacing a field that would be the same across all 1,000 emails, it should be done somewhere else. Ideally, it would be done via I would have this handled inside your email content prior to sending (until sections work). |
Hey @WadeShuler, Could you provide more details on how sections are broken? How have you tried using them? The more details we have the easier it should be to get to the bottom of the issue. Thank, Kyle |
This has been moved here. |
Acceptance Criteria:
Reference:
The text was updated successfully, but these errors were encountered: