#amazon-ses #aws-sdk-nodejs
Вопрос:
У меня есть лямбда для отправки электронных писем с использованием aws sdkv3 для javascript. Я отправляю на подтвержденный адрес электронной почты. Возвращенное исключение не говорит мне, в чем могут быть основные причины, поскольку это не одна из их распространенных ошибок.
Пожалуйста, посмотрите на мой код и скажите мне, видит ли кто-нибудь ошибку в шаблоне или коде.
exports.sendTestEmail = async (address, task_id) => {
console.log(`send email to ${address}`);
const tmpltChngParams = {
Destination: { /* required */
CcAddresses: [],
ToAddresses: [address]
},
Message: {
Body: {
Html: {
Data: '<p> There was a change made that has impacted Requirements Submission.'
'A task has been created to track this process.</p>',
Charset: 'utf-8'
},
Text: {
Data: 'There was a change made that has impacted Requirements Submission. '
'A task has been created to track this process.',
Charset: 'utf-8'
}
},
Subject: {
Data: ` System Notification: Task ${task_id}, `,
Charset: 'utf-8'
}
},
Source: 'aws-notifications-acct_num@someplace.com', /* required */
ReplyToAddresses: [],
};
const sesclient = new SES({ region: 'us-east-1' });
const command = new SendEmailCommand(tmpltChngParams);
try {
const sendPromise = await sesclient.send(command);
console.log(`Message ID = ${sendPromise.MessageId}`);
return sendPromise;
} catch (err) {
console.error(err, err.stack);
return err;
}
};
При попытке отправить я получаю следующее исключение в журналах:
2021-08-11T13:26:18.210Z e40afcd0-99f1-47ad-90bc-1c7d95f82699 ERROR MessageRejected: MessageRejected
at deserializeAws_querySendEmailCommandError (/var/task/node_modules/@aws-sdk/client-ses/dist/cjs/protocols/Aws_query.js:3368:41)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async /var/task/node_modules/@aws-sdk/middleware-serde/dist/cjs/deserializerMiddleware.js:6:20
at async /var/task/node_modules/@aws-sdk/middleware-signing/dist/cjs/middleware.js:12:24
at async StandardRetryStrategy.retry (/var/task/node_modules/@aws-sdk/middleware-retry/dist/cjs/defaultStrategy.js:56:46)
at async /var/task/node_modules/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js:6:22
at async Object.exports.sendTestEmail (/var/task/emailTest.js:34:25)
at async /var/task/routes/countryOwnersRoutes.js:77:16
at async /var/task/node_modules/lambda-api/index.js:231:23 {
'$fault': 'client',
'$metadata': {
httpStatusCode: 400,
requestId: '3f5f10fe-2c95-43e1-a720-a859bd7abc84',
extendedRequestId: undefined,
cfId: undefined,
attempts: 1,
totalRetryDelay: 0
}
} MessageRejected: MessageRejected
at deserializeAws_querySendEmailCommandError (/var/task/node_modules/@aws-sdk/client-ses/dist/cjs/protocols/Aws_query.js:3368:41)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async /var/task/node_modules/@aws-sdk/middleware-serde/dist/cjs/deserializerMiddleware.js:6:20
at async /var/task/node_modules/@aws-sdk/middleware-signing/dist/cjs/middleware.js:12:24
at async StandardRetryStrategy.retry (/var/task/node_modules/@aws-sdk/middleware-retry/dist/cjs/defaultStrategy.js:56:46)
at async /var/task/node_modules/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js:6:22
at async Object.exports.sendTestEmail (/var/task/emailTest.js:34:25)
at async /var/task/routes/countryOwnersRoutes.js:77:16
at async /var/task/node_modules/lambda-api/index.js:231:23
Комментарии:
1. Вы выяснили причину ошибки?