Skip to content
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

Closed
thinkingserious opened this issue Sep 23, 2016 · 7 comments
Closed

Send a Single Email to Multiple Recipients #301

thinkingserious opened this issue Sep 23, 2016 · 7 comments
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap

Comments

@thinkingserious
Copy link
Contributor

Acceptance Criteria:

  • A email object that represents the response body payload
  • A mail object that handles sending email objects, data validation and error handling

Reference:

@CyberPunkCodes
Copy link

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...

@thinkingserious
Copy link
Contributor Author

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

@thedustyrover
Copy link

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.

@thinkingserious
Copy link
Contributor Author

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

@CyberPunkCodes
Copy link

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

@thedailynathan - Substitution tags are supposed to be unique to that personalization object. Example: Dear -firstname- or Your username is: -username-.

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 sections. AFAIK, sections are broken and just don't work. Whether it is an issue with this repo, or the SendGrid API system itself, I am not sure.

I would have this handled inside your email content prior to sending (until sections work).

@kylearoberts
Copy link
Contributor

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

@thinkingserious
Copy link
Contributor Author

This has been moved here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests

4 participants