Aws-sdk-js: Add custom headers support to SES sendEmail

Created on 11 Jul 2019  路  2Comments  路  Source: aws/aws-sdk-js

Hello everybody!

Is your feature request related to a problem? Please describe.

The ses.sendEmail method is very convenient and it's all I need most of the time. Sometimes, however, I need to add a custom header. Instead of me just specifying this one single header in an option, I need to completely change the way I send the email and use ses.sendRawEmail, which requires me to assemble the message myself. It's great when I need the flexibility but it's annoying to have to use it just because of a single header.

Describe the solution you'd like

I would like the ability to specify extra headers in the ses.sendEmail method.

const params = {
  ...
  headers: {
    "X-Foo": "bar"
  }
};

ses.sendEmail(params, ...)

Describe alternatives you've considered

The alternative is to use ses.sendRawEmail but it's much more involved and 99% of the time I just emulate what ses.sendEmail does plus I push a bunch of additional headers.

guidance

Most helpful comment

Hey @jiripospisil,

Have you tried sending custome header with the request? You can do this via the SDK event listeners like this:

const request = ses.sendEmail(params);//no calllbacks here
request.on('build', (req) => {
    req.httpRequest.headers['X-Foo'] = 'something'
});
request.send(callback);

If it doesn't work, you might need to submit this feature reqeust to the service team on their forum.

All 2 comments

Hey @jiripospisil,

Have you tried sending custome header with the request? You can do this via the SDK event listeners like this:

const request = ses.sendEmail(params);//no calllbacks here
request.on('build', (req) => {
    req.httpRequest.headers['X-Foo'] = 'something'
});
request.send(callback);

If it doesn't work, you might need to submit this feature reqeust to the service team on their forum.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings