Email RealTimeTrigger

Email RealTimeTrigger

Certified

Trigger Flow on real-time emails

Listens to a mailbox and creates one execution per email. IMAP uses IDLE for push-style delivery; POP3 falls back to polling on interval (default PT60S) with SSL enabled by default—relax TLS checks only when required. Use MailReceivedTrigger instead when batching multiple emails.

yaml
type: io.kestra.plugin.email.RealTimeTrigger

Monitor Gmail inbox for new emails in real-time

yaml
id: realtime_email_monitor
namespace: company.team

tasks:
  - id: process_email
    type: io.kestra.plugin.core.log.Log
    message: |
      Real-time email received:
      Subject: {{ trigger.subject }}
      From: {{ trigger.from }}
      Date: {{ trigger.date }}
      Body: {{ trigger.body }}
      {% if trigger.attachments is not empty %}First attachment: {{ trigger.attachments[0].uri }}{% endif %}

triggers:
  - id: realtime_gmail_trigger
    type: io.kestra.plugin.email.RealTimeTrigger
    protocol: IMAP
    host: imap.gmail.com
    port: 993
    username: "{{ secret('GMAIL_USERNAME') }}"
    password: "{{ secret('GMAIL_PASSWORD') }}"
    folder: INBOX
    ssl: true

Monitor POP3 mailbox in real-time

yaml
id: realtime_pop3_monitor
namespace: company.team

triggers:
  - id: realtime_pop3_trigger
    type: io.kestra.plugin.email.RealTimeTrigger
    protocol: POP3
    host: pop.example.com
    port: 995
    username: "{{ secret('EMAIL_USERNAME') }}"
    password: "{{ secret('EMAIL_PASSWORD') }}"
    ssl: true
    interval: PT30S
Properties

Mail server host

Hostname or IP address for the mailbox connection

Password

Password or secret for mailbox authentication

Username

Username used to authenticate against the mailbox

Defaultfalse

Specifies whether a trigger is allowed to start a new execution even if a previous run is still in progress.

DefaultINBOX

Mail folder

Folder to monitor (IMAP only). Defaults to INBOX

DefaultPT1M

Check interval

Frequency for polling-based checks as an ISO-8601 duration. Default PT60S

Default26214400

Maximum attachment size

Maximum size in bytes of a single attachment stored in internal storage. Larger attachments keep their metadata but get a null uri. Default 26214400 (25MB)

Mail server port

Override the connection port. Defaults: IMAP 993/143, POP3 995/110 depending on SSL

DefaultIMAP
Possible Values
IMAPPOP3

Choose mail protocol

Protocol used to connect to the mailbox (IMAP or POP3). Defaults to IMAP

Defaulttrue

Use SSL/TLS

Enable TLS for the mailbox connection. Defaults to true

SubTypestring
Possible Values
CREATEDSUBMITTEDRUNNINGPAUSEDRESTARTEDKILLINGSUCCESSWARNINGFAILEDKILLEDCANCELLEDQUEUEDRETRYINGRETRIEDSKIPPEDBREAKPOINTRESUBMITTED

List of execution states after which a trigger should be stopped (a.k.a. disabled).

Defaultfalse

Trust all certificates

Skip TLS certificate and hostname validation (testing only). WARNING: this disables protection against man-in-the-middle attacks and must never be enabled in production. Defaults to false

Defaulttrue

A condition that determines whether the trigger should run.

A Pebble expression evaluated at trigger time. The trigger fires only when the expression evaluates to a truthy value (true, a non-empty string, a non-zero number). Use this to gate trigger execution on dynamic runtime values such as execution labels, flow variables, or environment conditions.

Email attachments

Metadata describing each attachment

Definitions
contentTypestring

Content type

Attachment MIME type reported by the sender

filenamestring

Attachment filename

Name as provided by the sender. Can be null when the sender did not provide one

sizeinteger

File size in bytes

Attachment size when provided by the server

uristring
Formaturi

Attachment URI

URI of the attachment stored in Kestra internal storage

SubTypestring

BCC email addresses

Addresses from the BCC header when available

Email body content

Text content extracted from the message parts

SubTypestring

CC email addresses

Addresses from the CC header

Formatdate-time

Email date

Message date as parsed from Received or Sent headers

Sender email address

Address from the From header

Message ID

Unique message identifier from the email headers

Email subject

Subject line of the received email

SubTypestring

Recipient email addresses

Addresses from the To header