AWS SESv2: Server Error (500) - SDK #5152
Unanswered
divyasatharasi
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Created a lambda function to send email using AWS SESv2 and Node.js, it is throwing Server Error:500 error
Error with @aws-sdk/client-sesv2.
Tested on Node.js v18.12.1
`const AWS = require("@aws-sdk/client-sesv2")
const { SESv2Client, BatchGetMetricDataCommand } = AWS;
const ses = new SESv2Client({
region: "ap-south-1",
credentials: {
accessKeyId: 'xxxxx',
secretAccessKey: 'xxxxxxxxxxxx'
},
});
exports.handler = async function (event) {
var params = {
Destination: {
ToAddresses: ["recipient_email@gmail.com"],
},
Message: {
Body: {
Text: { Data: "Report" },
},
};
const command = new BatchGetMetricDataCommand(params);
console.log(":: command :: ", command);
async function run() {
console.log(":: run called ")
try{
const data = await ses.send(command);
console.log(' :: data :: ', data)
} catch (error) {
console.log(' :: error :: ', error)
}
}
const res = await run();
console.log(": res : ", res)
};`
InternalFailure: UnknownError
at throwDefaultError (/opt/nodejs/node_modules/@smithy/smithy-client/dist-cjs/default-error-handler.js:8:22)
at /opt/nodejs/node_modules/@smithy/smithy-client/dist-cjs/default-error-handler.js:18:39
at de_BatchGetMetricDataCommandError (/opt/nodejs/node_modules/@aws-sdk/client-sesv2/dist-cjs/protocols/Aws_restJson1.js:1953:20)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async /opt/nodejs/node_modules/@smithy/middleware-serde/dist-cjs/deserializerMiddleware.js:7:24
at async /opt/nodejs/node_modules/@aws-sdk/middleware-signing/dist-cjs/awsAuthMiddleware.js:14:20
at async /opt/nodejs/node_modules/@smithy/middleware-retry/dist-cjs/retryMiddleware.js:27:46
at async /opt/nodejs/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:7:26
at async run (/var/task/index.js:38:18)
at async Runtime.exports.handler (/var/task/index.js:44:13) {
'$fault': 'client',
'$metadata': {
httpStatusCode: 500,
requestId: '65f8450a-9bd8-4f95-b7ca-4cad428e6eac',
extendedRequestId: undefined,
cfId: undefined,
attempts: 3,
totalRetryDelay: 127
}
}
Not sure if i am missing something here.
If anyone share a working sample code for sending email with attachment size of more than 10 MB using AWS SES v2, that would be helpful. Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions