擷取來自 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
,你會使用以下完整限定網址組態你的 Postmark 收件網路掛鉤https://actionmailbox:PASSWORD@example.com/rails/action_mailbox/postmark/inbound_emails
注意:組態你的 Postmark 收件時,請務必勾選標示為「*在 JSON 酬載中包含原始電子郵件內容」* 的方塊。Action Mailbox 需要原始電子郵件內容才能作用。
- C
執行個體一般方法
建立() 連結
原始碼: 顯示 | 在 GitHub 上
# File actionmailbox/app/controllers/action_mailbox/ingresses/postmark/inbound_emails_controller.rb, line 51 def create ActionMailbox::InboundEmail.create_and_extract_message_id! mail 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