Email MailSend

Email MailSend

Certified

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.

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

Send an email on a failed flow execution.

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

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

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

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

yaml
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

OAuth2 access token

Used when transportStrategy is SMTP_OAUTH2. Overrides password when provided; otherwise password is treated as the token

Attachments

Attachments to include, provided as a list or JSON string. Shown as separate files; some clients preview common types inline

BCC recipients

Optional semicolon-delimited RFC2822 addresses for blind carbon copy recipients

CC recipients

Optional semicolon-delimited RFC2822 addresses for carbon copy recipients

Embedded images

Images referenced from the HTML body via content IDs; accepts a list or JSON and expects common image MIME types

Sender address

RFC2822 From address presented to recipients

SMTP server host

Hostname or IP of the SMTP relay used to send emails

HTML body

HTML version of the message body. Can be paired with plainTextContent; most clients prefer HTML over plain text

SMTP password

Password or secret used for SMTP authentication

Plain text body

Plain-text alternative used when HTML is not supported

Reference (ref) of the pluginDefaults to apply to this task.

SMTP server port

Override the SMTP port. Defaults come from the transport strategy (SMTPS often 465, TLS 587)

Default10000

Session timeout (ms)

Maximum socket timeout while sending emails. Defaults to 10000 ms (10 seconds)

Email subject

Optional subject line; template expressions are allowed

Recipients (To)

Semicolon-delimited list of RFC2822 addresses for primary recipients

DefaultSMTPS
Possible Values
SMTPSMTPSSMTP_TLSSMTP_OAUTH2

SMTP transport strategy

Protocol used to send the email. Defaults to SMTPS; can be SMTP_TLS, SMTP, or SMTP_OAUTH2

SubTypestring

Trusted SSL/TLS hosts

Restrict TLS trust to the specified hosts when working with internal or self-signed servers

SMTP username

Username for authenticating to the SMTP server if required

Defaulttrue

Verify server identity

Performs TLS server identity checks. Defaults to true; disable only for self-signed or internal servers