fix: migrate to @aws-sdk/client-sesv2 for nodemailer v9 compatibility

This commit is contained in:
Kunthawat Greethong
2026-07-01 11:19:09 +07:00
parent b75ed98804
commit 33043260a9
3 changed files with 152 additions and 270 deletions

View File

@@ -13,7 +13,7 @@
import express from 'express';
import cors from 'cors';
import nodemailer from 'nodemailer';
import { SESClient } from '@aws-sdk/client-ses';
import { SESv2Client } from '@aws-sdk/client-sesv2';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
import { readFileSync, existsSync } from 'node:fs';
@@ -27,7 +27,7 @@ const sesConfigured = !!process.env.SES_ACCESS_KEY_ID;
let transporter;
if (sesConfigured) {
const ses = new SESClient({
const ses = new SESv2Client({
region: process.env.SES_REGION || 'ap-southeast-1',
credentials: {
accessKeyId: process.env.SES_ACCESS_KEY_ID,
@@ -35,7 +35,7 @@ if (sesConfigured) {
},
});
transporter = nodemailer.createTransport({
SES: { ses, aws: { SendRawEmailCommand: undefined } },
SES: { sesv2: true, ses },
});
}