AWS SES from NodeJS not DKIM signed?

2019-09-15 09:20发布

问题:

I am using nodemailer to send emails using SES

const nodemailer = require('nodemailer')
const sesTransport = require('nodemailer-ses-transport')

const transporter = nodemailer.createTransport(sesTransport({
  accessKeyId: '...',
  secretAccessKey: '...',
  region: 'us-east-1'
}))

When I try to send test emails from AWS SES Dashboard, it works. But when I send via code, it goes into spam. I've already followed the steps to "enable easy DKIM" http://docs.aws.amazon.com/ses/latest/DeveloperGuide/easy-dkim.html. When I check the verification status of DKIM on AWS Dashboard, its verified. Do I need to explicitly sign emails when sending via code? In the example from https://nodemailer.com/dkim/, I need a private key. Which private key isit? Where do I get it? Also what values do I put into domainName and keySelector?

let transporter = nodemailer.createTransport({
    service: 'Gmail',
    dkim: {
        domainName: 'example.com',
        keySelector: '2017',
        privateKey: '-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBg...'
    }
});

回答1:

Ok so I can close this. It appears nodemailer didnt correctly sign emails using DKIM. Using AWS SDK directly and calling setIdentityDkimEnabled to enable DKIM fixes things.