提问人:Happy Patel 提问时间:11/10/2023 更新时间:11/23/2023 访问量:25
InvalidClientTokenId:请求中包含的安全令牌无效 - 在 nestjs 中使用 AWS SES 服务发送电子邮件时出错
InvalidClientTokenId: The security token included in the request is invalid - Error getting while sending email using AWS SES service in nestjs
问:
欢迎.ejs
<p>Hey <%= name %>,</p>
<p>
Thanks for signing up for Nice App. We're very excited to have you on board.
</p>
<p>To get started using Nice App, please confirm your account below:</p>
<p>
<a href="<%= confirmation_url %>">Confirm you account</a>
</p>
<p>
If you're having trouble clicking the confirm account button, copy and paste
the below URL into your web browser.
</p>
<a href="<%= confirmation_url %>"><%= confirmation_url %></a>
我在src/core/templates/中有这个电子邮件模板
email.service.ts
async sendEmailAWSSES(
to: string,
subject: string,
template: string,
data: object,
) {
const config = {
accessKeyId: 'XXXXXXXXXXXXXXXXXX',
secretAccessKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
region: 'eu-west-1',
};
// Load the HTML template
const emailTemplateSource = fs.readFileSync(
`src/core/templates/${template}.ejs`,
'utf-8',
);
const emailTemplate = Handlebars.compile(emailTemplateSource);
// Compile the HTML template with data
const html = emailTemplate(data);
// Create sendEmail params
const params = {
Source: '[email protected]',
Destination: {
ToAddresses: [to],
},
Message: {
Body: {
Html: {
Charset: 'UTF-8',
Data: html,
},
},
Subject: {
Charset: 'UTF-8',
Data: subject,
},
},
ReplyToAddresses: [],
};
// Create the promise and SES service object
const sendPromise = await new AWS.SES(config).sendEmail(params).promise();
return sendPromise;
}
我有这个功能,可以使用AWS SES服务发送电子邮件 在发送我收到的电子邮件时
InvalidClientTokenId:请求中包含的安全令牌是 无效
请注意,我使用的是 AWS SES 的正确凭证。
答:
0赞
Happy Patel
11/23/2023
#1
我正在使用导致错误的过期凭据。
评论
~/.aws/credentials
aws configure