Karta.Inbound.Formats.Mailgun (Karta v1.0.0)

A Mailgun route's forward() post: the fields Mailgun sends to a destination URL when a route forwards a received message, so an application written for Mailgun's inbound parsing takes Karta's post unchanged.

The base fields are subject, sender (the envelope sender), from (the From field), recipient (the delivery's address as RCPT TO named it) and message-headers (every header field, in order, as a JSON array of [name, value] pairs). Mailgun's stripped-text, stripped-html and stripped-signature (the body without its quoted reply) are not sent: Mailgun leaves them out when it cannot parse a reply, and Karta does not parse one.

encoding is Mailgun's own choice by destination URL:

  • :form - form data with body-plain and body-html (as a list, as Mailgun sends it), and the attachments as attachment-count and attachment-<n> file parts of a multipart/form-data body (plain form data when there are none);
  • :mime - form data with the whole message as body-mime instead of the bodies and the attachments (the URL ending in mime), which is what an Action Mailbox Mailgun ingress needs;
  • :json - one JSON document with message-headers as a native array and attachments as a list of {filename, content-type, content} (base64).

Signature. timestamp (seconds) and a random 50-character token are signed with the endpoint's secret, as Mailgun signs: signature = HMAC-SHA256(secret, timestamp <> token), hex. In the form encodings they are fields; in JSON they are the headers X-Mailgun-Signature (over the whole body) and X-Mailgun-Timestamp. The secret is shown once when the endpoint is added; it is the signing key a receiver verifies with.

Summary

Functions

build(endpoint, delivery, message, raw, fields, now)

The request's headers and body.