Action Mailbox¶
Action Mailbox routes inbound email into mailbox classes. A raw message enters through an ingress, becomes an inbound-email record with a processing state machine, is matched to a mailbox by recipient, sender, or subject, and is processed with callbacks.
Inbound email¶
parse-message turns a raw RFC 822 string into a Message with unfolded
headers and a body:
1 2 3 4 5 6 7 8 9 10 11 12 | |
An InboundEmail wraps the raw message and tracks its state. It starts
pending and transitions through processing, then delivered, bounced, or
failed:
1 2 3 4 5 6 7 | |
Mailboxes¶
A mailbox subclasses Mailbox and implements process. Callbacks run around
processing, and the inbound email is marked delivered when process returns:
1 2 3 4 5 6 7 8 | |
perform-processing drives the lifecycle: it marks the email processing, runs
the before callbacks, calls process, runs the after callbacks, and marks the
email delivered.
Bouncing¶
Calling bounce inside processing marks the email bounced, runs the
on-bounce callbacks, and halts the rest of processing (the after callbacks are
skipped):
1 2 3 4 5 6 7 | |
Failures¶
An exception raised during processing marks the email failed. A matching
rescue-from handler runs; with no handler, the exception is re-raised:
1 2 3 4 5 | |
Routing¶
A Router maps inbound email to a mailbox. Each routing rule matches on
recipient, to, from, or subject, takes a matching predicate over the
inbound email, or all for a catch-all. Conditions accept an exact string or a
regex (subject and a string match as a substring); every condition in a rule
must match. The first matching rule wins:
1 2 3 4 5 6 7 8 9 10 11 | |
Ingress¶
An ingress receives raw email, records an InboundEmail, and hands it to the
router. RelayIngress takes one message at a time, as from a webhook relay:
1 2 3 4 5 | |
SourceIngress pulls from a generic source (an SMTP or POP mailbox), processing
every fetched message:
1 2 | |
Records persist through a repository.
MVC::Keayl::Mailbox::Ingress::Repository defines the interface and
MemoryRepository is the in-process implementation.
Relay endpoint¶
RelayController is the HTTP relay endpoint. Configure the ingress once, and the
controller hands each posted raw email to it:
1 | |
POSTing a raw message to the controller returns 204; with no configured
ingress it returns 503.