Skip to Content

SMTP Action

The smtp action delivers mail to an SMTP server. It is built for measuring and exercising delivery rather than for sending hand-written notifications: the message body is generated, and its size is set with length.

Basic Syntax

steps: - name: Send a probe mail uses: smtp with: addr: "localhost:2525" from: "sender@example.com" to: "recipient@example.com" subject: "Delivery probe" session: 1 message: 1 length: 500 test: res.code == 0 && res.sent > 0

Parameters

ParameterTypeRequiredDefaultDescription
addrStringYes-SMTP server as host:port
fromStringYes-Envelope sender
toStringYes-Envelope recipient
subjectStringNo""Subject line
myhostnameStringNo-Hostname used in the HELO / EHLO command
sessionIntegerNo1Number of SMTP sessions to open
messageIntegerNo1Messages to send per session
lengthIntegerNo0Size of the generated message body in bytes

There are no parameters for authentication, TLS, CC/BCC, a custom body or HTML. To include a report in the run output, use the step’s echo.

Response Object

FieldTypeDescription
res.codeInteger0 when every message was delivered
res.sentIntegerMessages delivered
res.failedIntegerMessages that failed
res.totalIntegerMessages attempted
res.errorStringError message, when delivery failed
res.maildataStringThe generated message, when it is text
res.filepathStringPath to the generated message, when it is binary

SMTP Examples

Several Sessions and Messages

steps: - name: Deliver 3 messages over 2 sessions id: bulk uses: smtp with: addr: "{{vars.smtp_addr}}" from: "{{vars.from_addr}}" to: "{{vars.to_addr}}" subject: "Bulk delivery test" myhostname: probe-client.local session: 2 message: 3 length: 750 test: res.code == 0 && res.sent == 6 outputs: sent: res.sent

Reporting the Result

- name: Delivery summary uses: hello echo: | Sent: {{outputs.bulk.sent}} Round trip: {{rt.duration}}
Updated at