Skip to Content

SMTPアクション

smtpアクションはSMTPサーバーへメールを配送します。任意の本文を書いて通知を送るためのものではなく、配送そのものを計測・負荷試験するためのアクションです。本文は自動生成され、サイズはlengthで指定します。

基本的な構文

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

パラメータ

パラメータ必須デフォルト説明
addrString必須-SMTPサーバー(host:port
fromString必須-エンベロープの送信者
toString必須-エンベロープの受信者
subjectString任意""件名
myhostnameString任意-HELO / EHLOで名乗るホスト名
sessionInteger任意1開くSMTPセッション数
messageInteger任意11セッションあたりの送信通数
lengthInteger任意0生成する本文のバイト数

認証、TLS、CC/BCC、任意の本文やHTMLを指定するパラメータはありません。実行結果にレポートを出したい場合はステップのechoを使います。

レスポンスオブジェクト

フィールド説明
res.codeIntegerすべて配送できたとき0
res.sentInteger配送できた通数
res.failedInteger失敗した通数
res.totalInteger試行した通数
res.errorString失敗時のエラーメッセージ
res.maildataString生成したメール(テキストの場合)
res.filepathString生成したメールのパス(バイナリの場合)

使用例

複数セッション・複数通の配送

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

結果をレポートする

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

関連項目

更新日時