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

Guidance on sending emails to many subusers (100+) #623

Open
arkitex opened this issue May 13, 2020 · 4 comments
Open

Guidance on sending emails to many subusers (100+) #623

arkitex opened this issue May 13, 2020 · 4 comments
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap

Comments

@arkitex
Copy link
Contributor

arkitex commented May 13, 2020

Issue Summary

I'm trying to use this library to send emails on behalf of many subusers - in the hundreds, if not thousands. It appears that the primary pattern is to use new Sendgrid(apiKey) in order to send - but that creates a FixedThreadPool with 8 threads. If I wish to send emails to even 10 subusers, this means I'll have 10 FixedThreadPools with 8 threads each - not desirable.

Is there any guidance on how to appropriately use this library for the above use-case? It looks like we could implemented SendgridAPI, but I'm hoping to avoid that if possible.

I'd use on-behalf-of, but that is not supported for mail.send.

Technical details:

  • sendgrid-java version: 4.4.8
@leothekim
Copy link

Definitely very curious how this use case is handled!

@childish-sambino
Copy link
Contributor

If all that's needed it to be able to set the On-Behalf-Of header at the request-level, then it's a pretty simple change to make SendGrid.api() merge the request headers with the client-level request headers. Then you could just do something like:

...
request.addHeader("On-Behalf-Of", "some-user");
Response response = sg.api(request);
...

Would this work for your usecase?

@childish-sambino childish-sambino added status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library labels May 21, 2020
@arkitex
Copy link
Contributor Author

arkitex commented May 21, 2020

I'm trying to actually send emails, and the Sendgrid docs claim that On-Behalf-Of is not supported for mail.send :(: https://sendgrid.api-docs.io/v3.0/how-to-use-the-sendgrid-v3-api/on-behalf-of

@childish-sambino
Copy link
Contributor

Ah, TIL. We could update the library to lazily-create the fixed thread pool, so it would be created on the first call to SendGrid.attempt, which you don't have to use and could just call SendGrid.api() instead.

@childish-sambino childish-sambino added status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap and removed status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library labels Jun 22, 2020
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

3 participants