
Email MailReceivedTrigger
CertifiedTrigger Flow on new mailbox messages
Email MailReceivedTrigger
Trigger Flow on new mailbox messages
Polls an IMAP or POP3 mailbox and starts one execution containing all newly detected emails. Uses the interval poll (default PT60S) against the INBOX with SSL enabled by default; relax SSL or set trustAllCertificates only when necessary.
type: io.kestra.plugin.email.MailReceivedTriggerExamples
Monitor Gmail inbox for new emails
id: email_monitor
namespace: company.team
tasks:
- id: process_email
type: io.kestra.plugin.core.log.Log
message: |
New email received:
Subject: {{ trigger.latestEmail.subject }}
From: {{ trigger.latestEmail.from }}
Date: {{ trigger.latestEmail.date }}
{% if trigger.latestEmail.attachments is not empty %}First attachment: {{ trigger.latestEmail.attachments[0].uri }}{% endif %}
triggers:
- id: gmail_inbox_trigger
type: io.kestra.plugin.email.MailReceivedTrigger
protocol: IMAP
host: imap.gmail.com
port: 993
username: "{{ secret('GMAIL_USERNAME') }}"
password: "{{ secret('GMAIL_PASSWORD') }}"
folder: INBOX
interval: PT30S
ssl: true
Properties
host *Requiredstring
Mail server host
Hostname or IP address for the mailbox connection
password *Requiredstring
Password
Password or secret for mailbox authentication
username *Requiredstring
Username
Username used to authenticate against the mailbox
allowConcurrent Non-dynamicboolean
falseSpecifies whether a trigger is allowed to start a new execution even if a previous run is still in progress.
folder string
INBOXMail folder
Folder to monitor (IMAP only). Defaults to INBOX
interval string
PT1MCheck interval
Frequency for polling-based checks as an ISO-8601 duration. Default PT60S
maxAttachmentSize integerstring
26214400Maximum 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)
port integerstring
Mail server port
Override the connection port. Defaults: IMAP 993/143, POP3 995/110 depending on SSL
protocol string
IMAPIMAPPOP3Choose mail protocol
Protocol used to connect to the mailbox (IMAP or POP3). Defaults to IMAP
ssl booleanstring
trueUse SSL/TLS
Enable TLS for the mailbox connection. Defaults to true
stopAfter Non-dynamicarray
CREATEDSUBMITTEDRUNNINGPAUSEDRESTARTEDKILLINGSUCCESSWARNINGFAILEDKILLEDCANCELLEDQUEUEDRETRYINGRETRIEDSKIPPEDBREAKPOINTRESUBMITTEDList of execution states after which a trigger should be stopped (a.k.a. disabled).
trustAllCertificates booleanstring
falseTrust 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
when string
trueA 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.
Outputs
emails array
All new emails found
List of every email fetched during this evaluation
io.kestra.plugin.email.MailService-EmailData
Email attachments
Metadata describing each attachment
io.kestra.plugin.email.MailService-AttachmentInfo
Content type
Attachment MIME type reported by the sender
Attachment filename
Name as provided by the sender. Can be null when the sender did not provide one
File size in bytes
Attachment size when provided by the server
uriAttachment URI
URI of the attachment stored in Kestra internal storage
BCC email addresses
Addresses from the BCC header when available
Email body content
Text content extracted from the message parts
CC email addresses
Addresses from the CC header
date-timeEmail 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
Recipient email addresses
Addresses from the To header
latestEmail
Latest email received
The most recent email that triggered this execution
io.kestra.plugin.email.MailService-EmailData
Email attachments
Metadata describing each attachment
io.kestra.plugin.email.MailService-AttachmentInfo
Content type
Attachment MIME type reported by the sender
Attachment filename
Name as provided by the sender. Can be null when the sender did not provide one
File size in bytes
Attachment size when provided by the server
uriAttachment URI
URI of the attachment stored in Kestra internal storage
BCC email addresses
Addresses from the BCC header when available
Email body content
Text content extracted from the message parts
CC email addresses
Addresses from the CC header
date-timeEmail 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
Recipient email addresses
Addresses from the To header
total integer
Total number of new emails found
Count of emails returned in this trigger cycle