Sendgrid-nodejs: Send by subuser

Created on 8 Feb 2019  路  6Comments  路  Source: sendgrid/sendgrid-nodejs

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.

unknown or a waiting for feedback question

All 6 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

umarhussain15 picture umarhussain15  路  3Comments

Chrischuck picture Chrischuck  路  3Comments

thinkingserious picture thinkingserious  路  4Comments

danielflippance picture danielflippance  路  4Comments

thidasapankaja picture thidasapankaja  路  4Comments