Is there no way to send from a subuser? Not seeing the authentication methods from @sendgrid/mail or within @sendgrid/client. Any points in the right direction would be greatly appreciated. Thank you.
Hello @btmdave,
You will need to add a custom header like so. But with On-Behalf-Of: subusername as the headers key.
With Best Regards,
Elmer
Perfect, thanks @thinkingserious, will give that a shot.
Awesome, please let me know how it goes.
You can see an example in our sendgrid-cli project: https://github.com/sendgrid/sendgrid-cli/blob/master/lib/sgclient.js#L46
@thinkingserious @aroach This doesn't actually seem to be working, the mail sent is going through our primary account. I did find this: https://sendgrid.api-docs.io/v3.0/how-to-use-the-sendgrid-v3-api/on-behalf-of which says that it doesn't work with the mail.send api?
This is how I'm sending it:
Mail sends fine, but the reporting is all through the primary account, nothing in the subaccount.
const msg = {
to: options.to,
from: options.from,
replyTo: options.replyTo,
subject: options.subject,
text: results.text,
html: results.html,
headers: {
"on-behalf-of": "SUBACCOUNT_USERNAME"
}
};
Hello @btmdave,
Have you tried using Token rather than Bearer for authentication?
With Best Regards,
Elmer