Home > Net >  Send emails with Nodemailer and AWS SES with imports
Send emails with Nodemailer and AWS SES with imports

Time:12-19

Although the official Nodemailer documentation explains how to use Nodemailer with AWS SES, the sample code uses require statements.

How to do the same with import statements?

CodePudding user response:

Nodemailer can be used with AWS SES with:

import nodemailer from 'nodemailer'
import * as aws from '@aws-sdk/client-ses'

const ses = new aws.SES({
  apiVersion: "2010-12-01",
  region: process.env.AWS_REGION,
  credentials: {
    secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
    accessKeyId: process.env.AWS_ACCESS_KEY_ID
  }
});

const transport = nodemailer.createTransport({
  SES: { ses, aws }
});

let info = await transporter.sendMail({
  from: '"Fred Foo            
  • Related