摄取来自 Postmark 的入站电子邮件。需要一个包含完整 RFC 822 消息的 RawEmail
参数。
使用 HTTP 基本访问身份验证对请求进行身份验证。用户名始终为 actionmailbox
,密码从应用程序的加密凭据或环境变量中读取。请参阅下面的用法部分。
请注意,在未加密的 HTTP 上,基本身份验证是不安全的。拦截到 Postmark 入口的明文请求的攻击者可以了解其密码。您应该只在 HTTPS 上使用 Postmark 入口。
返回
-
如果成功记录入站电子邮件并将其排队以路由到适当的邮箱,则返回
204 无内容
-
如果无法验证请求的签名,则返回
401 未授权
-
如果 Action Mailbox 未配置为接受来自 Postmark 的入站电子邮件,则返回
404 未找到
-
如果请求缺少必需的
RawEmail
参数,则返回422 不可处理的实体
-
如果未配置入口密码,或者 Active Record 数据库、Active Storage 服务或 Active Job 后端配置错误或不可用,则返回
500 服务器错误
用法
-
告诉 Action Mailbox 接受来自 Postmark 的电子邮件
# config/environments/production.rb config.action_mailbox.ingress = :postmark
-
生成一个强密码,Action Mailbox 可以使用该密码对请求到 Postmark 入口进行身份验证。
使用
bin/rails credentials:edit
将密码添加到应用程序的加密凭据中,位于action_mailbox.ingress_password
,Action Mailbox 将自动找到它action_mailbox: ingress_password: ...
或者,在
RAILS_INBOUND_EMAIL_PASSWORD
环境变量中提供密码。 -
配置 Postmark,将入站电子邮件转发到
/rails/action_mailbox/postmark/inbound_emails
,用户名为actionmailbox
,密码为之前生成的密码。如果您的应用程序位于https://example.com
,您将使用以下完全限定的 URL 配置您的 Postmark 入站 webhookhttps://actionmailbox:PASSWORD@example.com/rails/action_mailbox/postmark/inbound_emails
注意:在配置 Postmark 入站 webhook 时,务必选中标记为 *“在 JSON 有效负载中包含原始电子邮件内容”* 的框。Action Mailbox 需要原始电子邮件内容才能工作。
- C
实例公共方法
create() 链接
来源:显示 | 在 GitHub 上
# File actionmailbox/app/controllers/action_mailbox/ingresses/postmark/inbound_emails_controller.rb, line 51 def create ActionMailbox::InboundEmail.create_and_extract_message_id! params.require("RawEmail") rescue ActionController::ParameterMissing => error logger.error <<~MESSAGE #{error.message} When configuring your Postmark inbound webhook, be sure to check the box labeled "Include raw email content in JSON payload". MESSAGE head :unprocessable_entity end