Inbound Email
Inbound Email
An email intake turns an inbox into an automation trigger. DataMagik gives you a unique hosted email address; whenever a message arrives at that address, DataMagik runs the script you chose and hands it the email — subject, sender, body, and attachments included. Use it to process emailed purchase orders or invoices, kick off a workflow from a forwarded message, or file attachments automatically.
Creating an intake
- Go to Script Engine > Email Intakes and click to add a new intake.
- Give it a label (for example "PO Inbox"). DataMagik generates a unique hosted address for you from that label — you don't choose it.
- Pick the target script that should run for each message.
- Set your sender rules and optional subject filter (below).
- Make sure the intake is enabled, and save.
The generated address looks like this and is fixed once created:
po-inbox-9f3a1c@inbound.data-magik.com
Send or forward email to that address to trigger the script. To route your own mailbox into it, set up forwarding (or a mail rule) from your real inbox to the generated address.
Intake settings
| Setting | What it does |
|---|---|
| Label | A friendly name; also seeds the generated address. |
| Hosted address | The unique @inbound.data-magik.com
address DataMagik generates. Immutable after creation. |
| Target script | The script that runs for every accepted message. |
| Safe senders | An allowlist of addresses permitted to trigger the intake. This is the main anti-abuse control. |
| Accept any sender | When on, skips the allowlist and accepts mail from anyone. Use with care. |
| Subject filter | Optional. Only messages whose subject contains this text (case-insensitive) are processed. |
| Enabled | When off, mail to the address is logged but no script runs. |
What your script receives
The target script runs with the email delivered as its context:
function main(context) {
context.trigger // "email"
context.from // sender address
context.fromName // sender display name
context.to // the hosted address it was sent to
context.subject
context.textBody // plain-text body
context.htmlBody // HTML body
context.headers // { "reply-to": ..., "in-reply-to": ..., ... }
context.attachments // [ { name, contentType, size, base64, document_key }, ... ]
}
Each attachment arrives inline as base64 in attachments[].base64 (very large ones are
dropped and flagged oversized: true). Attachments are also saved to your company storage
and exposed as document_key, so a script can attach the file to an
approval for review. The intake itself does not run OCR — a script can
invoke OCR on an attachment if you need extracted fields.
Monitoring & troubleshooting
Each intake has a Messages console showing every email it received, whether it was
accepted or rejected (and why), and a Replay action to re-run a message through the
script. Triggered runs also appear in the target script's execution history with
triggered_by = "email".