Hello everyone, I've been trying to update my code from SES to SES v2 without success. I've done countless research and tried changing the code on my app, giving permissions to both myself and my email account but it's all useless, somehow my app still has the limit of 10MB per email. I'm using nodemailer and I have the latest SDK (^2.1644.0).
These are the policies that I'm using:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"ses:SendEmail",
"ses:SendBulkEmail"
],
"Resource": [
"arn:aws:ses:eu-west-3:111222333444:identity/MyUser",
"arn:aws:ses:eu-west-3:111222333444:template/*",
"arn:aws:ses:eu-west-3:111222333444configuration-set/*"
]
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "stmt1718786276145",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111222333444:root"
},
"Action": [
"ses:SendEmail",
"ses:BatchGetMetricData"
],
"Resource": "arn:aws:ses:my-region-1:111222333444:identity/myemail@mail.com",
"Condition": {}
}
]
}
And this is my code (NextJS + nodemailer):
import { SESv2Client, SendEmailCommand, type SendEmailCommandInput } from '@aws-sdk/client-sesv2';
import type Mail from 'nodemailer/lib/mailer';
import MailComposer from 'nodemailer/lib/mail-composer/index';
const ses = new SESv2Client({
apiVersion: '2019-09-27',
region: 'process.env.REGION',
credentials: {
secretAccessKey: process.env.SECRET_KEY,
accessKeyId: process.env.ACCESS_KEY
},
maxAttempts: 3
});
const mailOptions: Mail.Options = {
from: `${name} <mail@mail.com>`,
to: 'mail2@mail2.com',
subject: `${subject}`,
text: `${text}`,
html: `${htmlText}`,
attachDataUrls: false,
attachments: []
};
if (file !== undefined) {
mailOptions.attachments?.push(file as Attachment);
}
const rawMailData = await new MailComposer(mailOptions).compile().build();
try {
const input: SendEmailCommandInput = {
Content: {
Raw: {
Data: rawMailData
}
}
};
const command = new SendEmailCommand(input);
const response = await ses.send(command);
console.log(response);
resNumber = (response.MessageId != null) ? 200 : 500;
return NextResponse.json({ data: response }, { status: resNumber });
} catch (error: any) {
console.error(error);
return NextResponse.json({ error: error.message }, { status: 500 });
}
But when I run my app on my local machine, I do get to send emails up to 40MB in size, so I don't think the problem is there, rather on some kind of permission that I'm not implementing right
Make sure your local machine is using the same region of where your code is running. Most quotas are regional just to rule this out.
Do you have the same version of sdk locally as you do in your artifact/package?
My local machine is using the same region as my Amplify app; regarding the SDK, i'm sorry if this is a rookie mistake, but I don't know how to check my app's SDK version, I checked compiler's configuration where I have node set to v.20 and there is no option to set the SDK version
You could write out to log
var AWS = require("aws-sdk"); console.log('-- aws-sdk version--', AWS.VERSION);