
Email MailSend
CertifiedSend email from a Flow task
Email MailSend
Send email from a Flow task
Builds and sends an email over SMTP/SMTPS/SMTP_TLS/SMTP_OAUTH2 with optional HTML, attachments, and embedded images. Defaults to SMTPS transport with a 10-second session timeout and server identity verification; provide credentials or an OAuth2 access token when required.
type: io.kestra.plugin.email.MailSendExamples
Send an email on a failed flow execution.
id: unreliable_flow
namespace: company.team
tasks:
- id: fail
type: io.kestra.plugin.scripts.shell.Commands
runner: PROCESS
commands:
- exit 1
errors:
- id: send_email
type: io.kestra.plugin.email.MailSend
from: hello@kestra.io
to: hello@kestra.io
username: "{{ secret('EMAIL_USERNAME') }}"
password: "{{ secret('EMAIL_PASSWORD') }}"
host: mail.privateemail.com
port: 465 # or 587
subject: "Kestra workflow failed for the flow {{flow.id}} in the namespace {{flow.namespace}}"
htmlTextContent: "Failure alert for flow {{ flow.namespace }}.{{ flow.id }} with ID {{ execution.id }}"
Send an email with attachments.
id: send_email
namespace: company.team
inputs:
- id: attachments
type: ARRAY
itemType: JSON
tasks:
- id: send_email
type: io.kestra.plugin.email.MailSend
from: hello@kestra.io
to: hello@kestra.io
attachments: "{{ inputs.attachments | toJson }}"
Send an email with an embedded image.
id: send_email
namespace: company.team
inputs:
- id: embedded_image_uri
type: STRING
tasks:
- id: send_email
type: io.kestra.plugin.email.MailSend
from: hello@kestra.io
to: hello@kestra.io
embeddedImages:
- name: kestra.png
uri: "{{ inputs.embedded_image_uri }}"
contentType: image/png
Export Kestra audit logs to a CSV file and send it by email.
id: export_audit_logs_csv
namespace: company.team
tasks:
- id: ship_audit_logs
type: "io.kestra.plugin.ee.core.log.AuditLogShipper"
lookbackPeriod: P1D
logExporters:
- id: file
type: io.kestra.plugin.ee.core.log.FileLogExporter
- id: convert_to_csv
type: "io.kestra.plugin.serdes.csv.IonToCsv"
from: "{{ outputs.ship_audit_logs.outputs.file.uris | first }}"
- id: send_email
type: io.kestra.plugin.email.MailSend
from: hello@kestra.io
to: hello@kestra.io
username: "{{ secret('EMAIL_USERNAME') }}"
password: "{{ secret('EMAIL_PASSWORD') }}"
host: mail.privateemail.com
port: 465 # or 587
subject: "Weekly Kestra Audit Logs CSV Export"
htmlTextContent: "Weekly Kestra Audit Logs CSV Export"
attachments:
- name: audit_logs.csv
uri: "{{ outputs.convert_to_csv.uri }}"
contentType: text/csv
triggers:
- id: schedule
type: io.kestra.plugin.core.trigger.Schedule
cron: 0 10 * * 5
Send an email using an internal mail server with self-signed certificate and specific trusted hosts.
id: send_email_internal
namespace: company.team
tasks:
- id: send_email
type: io.kestra.plugin.email.MailSend
from: noreply@company.local
to: admin@company.local
username: "{{ secret('INTERNAL_SMTP_USER') }}"
password: "{{ secret('INTERNAL_SMTP_PASSWORD') }}"
host: mail.company.local
port: 587
transportStrategy: SMTP_TLS
subject: "Internal notification"
htmlTextContent: "This email was sent from an internal mail server"
verifyServerIdentity: false
trustedHosts:
- mail.company.local
- smtp.company.local
- 192.168.1.100
Properties
accessToken string
OAuth2 access token
Used when transportStrategy is SMTP_OAUTH2. Overrides password when provided; otherwise password is treated as the token
attachments arraystring
Attachments
Attachments to include, provided as a list or JSON string. Shown as separate files; some clients preview common types inline
bcc string
BCC recipients
Optional semicolon-delimited RFC2822 addresses for blind carbon copy recipients
cc string
CC recipients
Optional semicolon-delimited RFC2822 addresses for carbon copy recipients
embeddedImages arraystring
Embedded images
Images referenced from the HTML body via content IDs; accepts a list or JSON and expects common image MIME types
from string
Sender address
RFC2822 From address presented to recipients
host string
SMTP server host
Hostname or IP of the SMTP relay used to send emails
htmlTextContent string
HTML body
HTML version of the message body. Can be paired with plainTextContent; most clients prefer HTML over plain text
password string
SMTP password
Password or secret used for SMTP authentication
plainTextContent string
Plain text body
Plain-text alternative used when HTML is not supported
pluginDefaultsRef Non-dynamicstring
Reference (ref) of the pluginDefaults to apply to this task.
port integerstring
SMTP server port
Override the SMTP port. Defaults come from the transport strategy (SMTPS often 465, TLS 587)
sessionTimeout integerstring
10000Session timeout (ms)
Maximum socket timeout while sending emails. Defaults to 10000 ms (10 seconds)
subject string
Email subject
Optional subject line; template expressions are allowed
to string
Recipients (To)
Semicolon-delimited list of RFC2822 addresses for primary recipients
transportStrategy string
SMTPSSMTPSMTPSSMTP_TLSSMTP_OAUTH2SMTP transport strategy
Protocol used to send the email. Defaults to SMTPS; can be SMTP_TLS, SMTP, or SMTP_OAUTH2
trustedHosts array
Trusted SSL/TLS hosts
Restrict TLS trust to the specified hosts when working with internal or self-signed servers
username string
SMTP username
Username for authenticating to the SMTP server if required
verifyServerIdentity booleanstring
trueVerify server identity
Performs TLS server identity checks. Defaults to true; disable only for self-signed or internal servers