1

I'm running a notification node express backend service via AWS Lambda to send emails via ses and catch bounces and complaints to blacklist them on certain conditions. I'm using nodemailers Mailcomposer module to compose a raw email.

here is my code to send the emails

var AWS          = require("aws-sdk");
var mailComposer = require('nodemailer/lib/mail-composer');

var ses = new AWS.SES({
...
}

let mailOptions = {
  from : "sender name <user@domain.com>",
  to : ["bounce@simulator.amazonses.com"],
  replyTo : 'demo@demo.com',
  inReplyTo : '12345-message-id', // The message-id this message is replying
  subject : "subject of this email",
  text : Buffer.from("plaint text version of the email", 'utf-8'), 
  html : Buffer.from("<div><p>Hello Customer</p></div>", 'utf-8'),

  // AND MY CUSTOM HEADER
  headers : {"customHeader" : "13371337"}, 

};
let mail = new mailComposer(mailOptions);
mail.compile().build((err, mailData) => {

  if(err){
    console.log("error occured compiling");
    console.log(err);
    return;
  }

  var params = {
    RawMessage : {
      Data : mailData
    },
  };

  ses.sendRawEmail(params, (err, data) => {
    if(err){
      console.log("error occured sending email");
      console.log(err);
    }else{
      console.log("success");
      console.log(data);
    }
  });
});

I have also enabled "Include Original Headers" in the domains SES Notification settings, the email is send successfully, but my notification backend service does not receive the customHeader anywhere ...

sami_analyst
  • 1,751
  • 5
  • 24
  • 43
  • `nodemailer/mailcomposer` package is currently archived by its owner. I would suggest to check out alternatives like the followin resources. https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/ses-examples-sending-email.html – Yajairo87 Aug 06 '19 at 17:46

0 Answers0