使用AWS API Gateway通过AWS SES POST电子邮件

编程入门 行业动态 更新时间:2024-10-11 17:25:39
本文介绍了使用AWS API Gateway通过AWS SES POST电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在从一个应用程序中设置一个API,该API允许该应用程序的用户与某人联系以进行跟进,但隐藏发件人的电子邮件地址(并允许在不发行该新版本的应用程序的情况下对其进行更改).

I'm setting up an API from an App which allows the App user to contact someone for follow-up, but hides the email address from the sender (and allows it to be changed without a new release of the App).

我设法设置了一个AWS API Gateway GET方法,该方法直接通过SES发送电子邮件

I've managed to setup an AWS API Gateway GET method which sends email directly via SES

...aws/em/send/en?body=The+email+is+here

使用路径替代

Action=SendEmail &Source=source%40mydomain &Destination.ToAddresses.member.1=follow.up%40anydomain &Message.Subject.Data=Request+For+Followup &Message.Body.Text.Data={body}

我更喜欢使用 POST 方法-但实际上很难弄清楚Action参数应包含的内容以及如何创建映射模板-甚至即使它尽管AWS文档中确实包含了$util.urlEncode()函数,但无需诉诸lambda函数就可以创建application/x-www-form-urlencoded请求.

I would much prefer to use a POST method - but am really struggling to work out what should go in the Action parameter and how to create the mapping template - or even if it is possible to create an application/x-www-form-urlencoded request without having to resort to a lambda function - although the AWS documentation does include a $util.urlEncode() function.

docs .aws.amazon/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html

我正在尝试对AWS Gateway使用POST方法,对请求正文中的内容使用POST到SES,但是我不清楚如何创建映射模板,并且找不到任何示例SES.

I am trying to use a POST method to AWS Gateway and a POST to SES with the contents in the request body, but it is just not clear to me how to create the mapping template and I can't find any examples for SES.

使用映射模板对其进行测试(按照文档)

Testing it with the mapping template (as per the example in the documentation)

Source=source%40mydomain &Destination.ToAddresses.member.1=follow.up%40anydomain &Message.Subject.Data=Request+For+Followup &Message.Body.Text.Data=The+message+goes+here

并且内容类型application/x-www-form-urlencoded AWS网关给出错误:

And a content type application/x-www-form-urlencoded AWS gateway gives the error:

{ "message": "Unsupported Media Type" }

如果我使用映射模板

{ "Action":"SendEmail", "Source":"source@mydomain", "Destination":{ "ToAddresses":{ "member":["follow.up@anydomain"] } }, "Message":{ "Subject": { "Data":"Request For Followup" }, "Body":{ "Text":{ "Data":"The message goes here" } } } }

并且内容类型为application/json AWS Gateway会给出错误

and a content type of application/json AWS gateway gives the error

{ "Output": { "__type": "com.amazon.coral.service#UnknownOperationException", "message": null }, "Version": "1.0" }

推荐答案

您的映射模板配置必须为POST格式,而不是JSON格式,因为SES服务不支持json( docs.aws.amazon/ses/latest/DeveloperGuide/query- interface-examples.html ),例如,此配置已为我完成

Your mapping template configuration must be in a POST format, not in the JSON, since SES service doesn't support json (docs.aws.amazon/ses/latest/DeveloperGuide/query-interface-examples.html) for example this config has worked out for me

Action=SendEmail& Message.Body.Text.Data=Some+text& Message.Subject.Data=New+message& ReturnPath=some@mail.io &Destination.ToAddresses.member.1=some@destination &Source=your@sender.email

此外,仅在上述情况下,您的路径覆盖率必须为SendEmail

Also, your path override must be SendEmail only for the case above

更多推荐

使用AWS API Gateway通过AWS SES POST电子邮件

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

发布评论

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

>www.elefans.com

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