Lambda上的AWS SES

编程入门 行业动态 更新时间:2024-10-11 05:27:11
本文介绍了Lambda上的AWS SES-无法(静默)发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用amazon服务显示已标记'aws-lambda'的问题" rel ="tag"> aws-lambda ,以便将电子邮件发送给经过验证的收件人.

I'm trying to use the amazon-ses service on a aws-lambda in order to send an email to verified recipients.

我正在关注这很简单该教程显示了一个简单的 nodejs 函数的问题:

I'm following this simple tutorial which shows a simple nodejs function:

var aws = require('aws-sdk'); var ses = new aws.SES({region: 'us-east-1'}); exports.handler = (event, context, callback) => { var params = { Destination: { ToAddresses: ["recipientEmailAddress"] }, Message: { Body: { Text: { Data: "Test" } }, Subject: { Data: "Test Email" } }, Source: "sourceEmailAddress" }; ses.sendEmail(params, function (err, data) { callback(null, {err: err, data: data}); if (err) { console.log(err); context.fail(err); } else { console.log(data); context.succeed(event); } }); };

以下政策是lambda角色的一部分:

The following policy is part of the lambda's role:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ses:SendEmail" ], "Resource": "*" } ] }

出于某种原因,此lambda函数无法发送任何电子邮件,并且在该函数的CloudWatch Log组内未提供任何状态信息:

For some reason, this lambda function fails to send any emails and it doesn't provide any status information inside the function's CloudWatch Log group:

REPORT RequestId: XXX Duration: 534.59 ms Billed Duration: 600 ms Memory Size: 128 MB Max Memory Used: 117 MB

任何帮助将不胜感激.

编辑:我在沙盒模式中工作,并且 source 和收件人都是来自该地区的经过验证的电子邮件代码中提到的内容(它也反映在日志中-不会引发任何错误).

I work in sandbox-mode and both source and recipient are verified emails from the region mentioned in the code (It is also reflected in the logs - no errors being thrown).

我在SO中发现了以下问题-但对我的案子没有相关答案:

I Found the following questions in SO - but no relevant answer to my case:

在AWS Lambda函数中通过AWS SES发送电子邮件

AWS SES发送电子邮件lambda每次都不发送

SES电子邮件未发送

在发送邮件时出现python错误亚马逊ses与aws lambda

推荐答案

我认为 context.succeed 已过时.您也可以使用 async/await :

I think context.succeed is deprecated. Also you can use async/await:

exports.handler = async (event, context) => { var params = { Destination: { ToAddresses: ["recipientEmailAddress"] }, Message: { Body: { Text: { Data: "Test" } }, Subject: { Data: "Test Email" } }, Source: "sourceEmailAddress" }; const data = ses.sendEmail(params).promise() return data };

更多推荐

Lambda上的AWS SES

本文发布于:2023-11-23 20:09:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622738.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Lambda   AWS   SES

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!