RealTimeTrigger icon
Return icon
If icon
Log icon
SlackIncomingWebhook icon

Inbound Email Sender Domain Compliance Gate

Monitor a shared mailbox for emails from unauthorized sender domains and alert Slack before a spoofed or unapproved sender goes unnoticed.

Categories
Infrastructure

A shared mailbox - a support alias, a partner-intake address, a vendor-facing inbox - has no built-in way to flag mail from a domain nobody approved: a spoofed lookalike of a real partner, or simply an unexpected sender slipping past manual review. This blueprint listens to the mailbox in real time and alerts Slack the instant an email arrives from a domain outside a configured allowlist, without ever marking the message as read or touching the mailbox otherwise.

How it works

  1. inbound_email_received (io.kestra.plugin.email.RealTimeTrigger) opens the configured IMAP folder read-only and starts one execution per arriving email, using IMAP IDLE for push-style delivery. Shipped disabled; point vars.imap_host/imap_port/imap_ssl/imap_folder at a real or local test mailbox and verify a manual trigger of the flow first.
  2. extract_sender_domain (io.kestra.plugin.core.debug.Return) pulls the domain out of trigger.from.
  3. evaluate_sender_compliance (io.kestra.plugin.core.flow.If) branches on whether that domain is present in allowed_sender_domains.
    • then (HEALTHY): log_sender_compliant records the pass.
    • else (UNAUTHORIZED_SENDER_DOMAIN_DETECTED): alert_unauthorized_sender reports the sender, subject, and domain to Slack.
  4. log_audit_complete always runs last, printing the sender, domain, and subject regardless of which branch fired.
  5. The errors block alerts Slack separately if the flow itself fails outright - for example a From header the extraction logic cannot parse.

What you get

  • A real-time, non-destructive compliance gate on inbound mail, built on IMAP IDLE push delivery rather than a polling probe - verified from the trigger's own source to open the folder READ_ONLY, so this gate can never itself mark a message read, move it, or delete it.
  • The exact sender address, subject, and domain surfaced in the Slack alert itself, so a reviewer can act without opening the mailbox.
  • A worked example of io.kestra.plugin.email.RealTimeTrigger - a capability added to this plugin on October 1, 2026 - used for a security/governance compliance gate, with no prior blueprint coverage of this specific trigger for this purpose in this repository (one existing blueprint uses the same trigger for AI-driven sponsorship-email business triage, a different use case entirely).

Who it's for

  • Security and operations teams who own a shared mailbox and want automatic flagging of mail from domains nobody approved, instead of relying on every reviewer to notice a lookalike domain by eye.
  • Teams receiving partner, vendor, or customer intake email who want a lightweight allowlist gate without standing up a full email security gateway.
  • Anyone evaluating the email plugin who wants a worked example of its newest real-time IMAP trigger used for governance monitoring.

Why orchestrate this with Kestra

IMAP itself has no allowlist or domain-governance primitive - a mail server either accepts a message or it doesn't, with no per-domain policy hook exposed to a downstream workflow. Kestra supplies the real-time trigger, the HEALTHY/UNAUTHORIZED_SENDER_DOMAIN_DETECTED classification as a first-class branch, and an execution history showing exactly which emails were flagged and when.

Prerequisites

  • An IMAP-accessible mailbox (a real one, or a local test server such as GreenMail, whose official open-source Docker image exposes IMAP on port 3143 and IMAPS on port 3993 - update vars.imap_host/imap_port/imap_ssl accordingly).
  • Mailbox credentials with read access to the monitored folder.
  • A Slack incoming webhook for alerts.

Local testing: GreenMail's Docker image requires no account or license and is built specifically for this kind of integration testing, satisfying this blueprint's testability without any paid or enterprise-only service.

Secrets

  • MAILBOX_USERNAME / MAILBOX_PASSWORD: credentials for io.kestra.plugin.email.RealTimeTrigger.
  • SLACK_WEBHOOK_URL: Slack incoming webhook used by alert_unauthorized_sender and the errors block.
  • In Kestra OSS (no Enterprise secrets backend), secrets are supplied as environment variables prefixed SECRET_, base64-encoded - for example SECRET_MAILBOX_PASSWORD=$(echo -n '<your-password>' | base64) - and read back in flows with {{ secret('NAME') }}.

Inputs

  • allowed_sender_domains (STRING, must be replaced): comma-separated list of trusted sender domains.

Variables

  • imap_host / imap_port / imap_ssl / imap_folder: IMAP connection details fed to the trigger, defaulted to GreenMail's local Docker IMAPS port for easy local testing.

Outputs

  • trigger.from / .subject / .to / .cc / .bcc / .date / .body / .messageId / .attachments: every field verified from the trigger's own MailService.EmailData output model.
  • outputs.extract_sender_domain.value (String): the parsed sender domain used for classification.

Quick start

  1. Run GreenMail locally (docker run -p 3993:3993 -p 3143:3143 greenmail/standalone:latest or the project's own documented Docker command) or point this at a real mailbox.
  2. Add the MAILBOX_USERNAME, MAILBOX_PASSWORD, and SLACK_WEBHOOK_URL secrets, and set allowed_sender_domains.
  3. Enable the flow and send a test email from an allowed domain; confirm log_sender_compliant fires.
  4. Send a test email from a domain not on the allowlist; confirm alert_unauthorized_sender fires with the correct sender, subject, and domain.
  5. Point this at a real production mailbox's IMAP settings once you trust the check.

How to extend

  • Add a second classification layer checking trigger.subject or trigger.body against a list of known phishing/scam keyword patterns, alongside the domain check this blueprint already performs.
  • Cross-reference trigger.attachments against an allowed file-extension list, flagging executable or script attachments from any sender, not just unauthorized domains.
  • Add a remediation branch that moves a flagged email to a quarantine folder via a separate IMAP client call, behind an explicit approval gate - deliberately kept out of this gate so the monitoring path never moves or deletes mail on its own.

Pitfalls

  • Sender domain extraction is a best-effort parse of a free-text header, not a validated email-address parser - verified from the trigger's own from field being a raw string from the From header. Internationalized domains, unusual quoting, or multiple addresses in one From header can produce an unexpected result; this blueprint does not use a full RFC 5322 address parser.
  • IMAP IDLE requires a server that supports the IDLE extension - most modern IMAP servers do, including GreenMail, but a server that only supports POP3 or lacks IDLE falls back to interval polling per the trigger's own documented behavior, which is slower to react.
  • This gate only sees mail arriving after it is enabled - it cannot retroactively classify messages already sitting in the folder before the trigger started listening.
  • This blueprint is UNTESTED against a live mailbox or Kestra engine. The trigger's READ_ONLY folder behavior and the EmailData output fields are taken verbatim from the plugin's own source - but no Kestra engine was run to execute this flow end to end.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.