-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SESv2 Support with AWS SDK v3 #1430
Comments
Is there any benefit in using |
The SES v2 API supports e-mail messages up to 40MB in size. The v1 API only supports 10MB. I'll have a go at forking the project and adding it in with updated tests 👍 |
This issue is stale because it has been open for 30 days with no activity. |
any update on this? thanks |
any updates? |
Still on my todo list, I'll pick it up this Thursday and submit the PR 👍
|
This works for me:
|
This issue is stale because it has been open for 30 days with no activity. |
Hi, @adamprescott Did you have time to dive in more in the code and make some changes? |
This issue is stale because it has been open for 30 days with no activity. |
Hi team 👋 . Very much waiting for this one. Any updates? |
This issue is stale because it has been open for 30 days with no activity. |
Looking forward to this one too |
Just passing by, this would be handy 👍 |
This issue is stale because it has been open for 30 days with no activity. |
Not stale |
Any update on this? AWS has been moving away from SES v1. We also need to support large message size. |
Any update on this? |
SESV2 and SDK V3 are very different from the old SDK. It would require a lot of changes by the authors to catch up. I am able to use the new SDK with mimetext to send email with attachment via SESV2. import {createMimeMessage} from 'mimetext'; |
This issue is stale because it has been open for 30 days with no activity. |
Indeed, I'd still like to have a direct integration with SESv2. For now, the solution posted by @aymanmh is a fine alternative. |
+1 - would love SES v2 support for AWS SDK v3 for 40mb file support. @adamprescott Did you make any progress on the fork? |
This worked well for us except for Bcc's. For some reason they got ignored by aws and were not sent. This was fixed by also defining the |
This issue is stale because it has been open for 30 days with no activity. |
This issue was closed because it has been inactive for 14 days since being marked as stale. |
Up |
What do you think about exposing
|
Based on @dyaacov comment, I adapted the code and it's working for me in a NestJS project. Sharing the code in case anyone needs it.
|
According to https://docs.aws.amazon.com/ses/latest/dg/quotas.html the 40 MB limit is also available when using SMTP and Nodemailer supports SMTP. Are there any disadvantages to use SMTP until Nodemailer supports SESv2 natively? |
For us the issue was authentication, with SMTP you have to create SMTP Credentials which for us was a no-go. We're using it in a NestJS context and I use the following workaround to use the v2 api. import { SendEmailCommand, SESv2Client } from '@aws-sdk/client-sesv2';
MailerModule.forRootAsync({
useFactory: (
configService: ConfigService
) => {
class SendRawEmailCommand extends SendEmailCommand {
constructor(params) {
const input = {
Content: {
Raw: {
Data: params.RawMessage.Data,
},
},
FromEmailAddress: params.Source,
Destination: {
ToAddresses: params.Destinations,
},
};
super(input);
}
}
return {
transport: {
SES: {
ses: new SESv2Client({
region: configService.get('AWS_REGION'),
credentials: fromContainerMetadata(),
}),
aws: {
SendRawEmailCommand,
},
},
},
};
},
inject: [ConfigService],
}) |
According to AWS SES blog: https://aws.amazon.com/blogs/messaging-and-targeting/using-one-click-unsubscribe-with-amazon-ses/. In order to use one-click unsubscribe with SES to compliant with bulk email sending rules, need to utilize ses v2 api. Might be another reason for nodemailer to support SESv2. |
based on dyaacov comment above (old sdk), this works flawlessly for sdk v3: import { SESv2Client, SendEmailCommand } from '@aws-sdk/client-sesv2';
import MailComposer from 'nodemailer/lib/mail-composer/index.js';
const sesv2Client = new SESv2Client({ region: process.env.AWS_REGION });
/* fill the mail options as usual , my email object looks like this
{
"from": {"name":"Sender", "address": "example_sender@example.com"},
"text_body": "some text",
"subject": "Email Subject",
"to": [{"name":" A,B", "address":"example_sender@example.com"}],
"cc": [{"address":"example_1@example.com"},{"address":"example_1@example.com"}],
}
*/
const mailOptions = {
from: email.from,
subject: email['subject'] ? email.subject : '',
html: email['html_body'] ? email.html_body : '',
text: email['text_body'] ? email.text_body : '',
to: email['to'] ? email.to : '',
cc: email['cc'] ? email.cc : '',
bcc: email['bcc'] ? email.bcc : '',
attachments: hasAttachments ? email.attachments : [],
};
const rawMailData = await new MailComposer(mailOptions).compile().build();
const input = {
Content: {
Raw: { Data: rawMailData },
},
};
const cmd = new SendEmailCommand(input);
const resp = await sesv2Client.send(cmd); |
Only issue with defining custom In the recipient inbox it is shown without a nice sender name.
In the constructor, there is only
|
AWS SDK for JavaScript v2 will enter maintenance mode on September 8, 2024 and reach end-of-support on September 8, 2025. For more information, check blog post at https://a.co/cUPnyil |
To clarify, in order to use SMTP with SES, you can only authenticate as an IAM user. This is stated on Obtaining Amazon SES SMTP credentials: Crucially, this means you won't be able to send emails as an IAM role via SES SMTP. |
Please watch out for a behavioral difference between the SESv2 DetailsIn SESv1, In SESv2 however, This may be what @ihmpavel was saying in #1430 (comment), but I'm not entirely sure... Solutions...?If you always expect to have a class SendRawEmailCommand extends SendEmailCommand {
constructor(params) {
const input = {
Content: {
Raw: {
Data: params.RawMessage.Data,
},
},
- FromEmailAddress: params.Source,
Destination: {
ToAddresses: params.Destinations,
},
};
super(input);
}
}
const transport = nodemailer.createTransport({
SES: {
aws: { SendRawEmailCommand },
ses: new SESv2Client({ region: 'us-west-2' }),
},
}); Stepping back, when an official SESv2 nodemailer/lib/ses-transport/index.js Lines 229 to 236 in baa28f6
where the |
I am using solution I found by myself few weeks ago, but I'll check @mxxk as well
Full code (suitable for production)
|
@ihmpavel in your example, I noticed you're providing two from-like addresses: await transporter.sendMail({ ses: { Source: `NAME <john@example.com&`, // <- check this line }, to: '...' from: '...', subject: '...', ... This works, assuming I find the example a little counterintuitive, because It's up to you of course, but It might be clearer if you stop passing @@ -10,7 +10,6 @@ class SendRawEmailCommand extends SendEmailCommand {
Data: params.RawMessage.Data,
},
},
- FromEmailAddress: params.Source, // maybe not required based on https://github.com/nodemailer/nodemailer/issues/1430#issuecomment-2224339555
Destination: {
ToAddresses: params.Destinations,
},
@@ -32,9 +31,6 @@ export const createEmailTransporter = () =>
const transporter = createEmailTransporter()
await transporter.sendMail({
- ses: {
- Source: `NAME <john@example.com>`, // <- check this line
- },
to: '...'
from: '...',
subject: '...',
|
Any updates? Thank you |
Just wondering if there are any plans to add SESv2 Support with the v3 SDK?
If not, I'll have a go at submitting a PR to update ses-transport to detect the use of the V2 API with the V3 SDK.
My current work-around is this:
The text was updated successfully, but these errors were encountered: