Inbound Email

Updated Jul 21, 2026
DataMagik Automate

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.

Who can set this up: Email intakes are configured by a company administrator (the DataMagik - Security permission). Find them at Script Engine > Email Intakes.

Creating an intake

  1. Go to Script Engine > Email Intakes and click to add a new intake.
  2. Give it a label (for example "PO Inbox"). DataMagik generates a unique hosted address for you from that label — you don't choose it.
  3. Pick the target script that should run for each message.
  4. Set your sender rules and optional subject filter (below).
  5. 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

SettingWhat it does
LabelA friendly name; also seeds the generated address.
Hosted addressThe unique @inbound.data-magik.com address DataMagik generates. Immutable after creation.
Target scriptThe script that runs for every accepted message.
Safe sendersAn allowlist of addresses permitted to trigger the intake. This is the main anti-abuse control.
Accept any senderWhen on, skips the allowlist and accepts mail from anyone. Use with care.
Subject filterOptional. Only messages whose subject contains this text (case-insensitive) are processed.
EnabledWhen off, mail to the address is logged but no script runs.
Delivery is filtered before it triggers. Auto-replies, bounces, and system mail are ignored; the sender must be on your safe-sender list (unless Accept any sender is on); and if you set a subject filter, it must match. Rejected messages are recorded with a reason so you can see why nothing ran.

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".

"I sent an email but nothing happened." First check the intake's Messages console — a rejected entry tells you the reason (sender not allowlisted, subject filter, intake disabled, duplicate). If the message isn't listed at all, the address was likely mistyped or the mail never reached DataMagik.
Related: To trigger a script over HTTP instead, see Script Webhooks; to run one on a schedule, see Script Schedules. To design the emails DataMagik sends, see Email Templates.
Was this page helpful?