SES v2 is not letting me send emails bigger than 10MB

0

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 });
}
1 Answer
2

The default message size limit in Amazon SES remains at 10MB for email sending and 30MB for email receiving, however AWS customers can now request a limit increase to send/receive email messages that contain up to a 40MB message size (including the email text, images, attachments and the MIME encoding). This limit increase can be requested via the AWS Support Center.

https://aws.amazon.com/about-aws/whats-new/2021/09/amazon-ses-emails-message-40mb/

profile picture
EXPERT
answered a year ago
profile picture
EXPERT
reviewed a year ago
EXPERT
reviewed a year ago
  • 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);

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions