sendmail

Sends input data as an email using the system SMTP configuration.

Command properties

PropertyDescription
Command typeTransforming
Required permissionAdministrator
License usageN/A
Parallel executionSupported
Distributed executionNot supported

Syntax

sendmail [html=BOOL]

Options

html=BOOL
When set to t, sends the email body in HTML format.

Input fields

FieldTypeRequiredDescription
tostringRequiredRecipient email address. Separate multiple addresses with commas (,).
subjectstringRequiredEmail subject.
messagestringRequiredEmail body.
ccstringOptionalCC email address. Separate multiple addresses with commas (,).
bccstringOptionalBCC email address. Separate multiple addresses with commas (,).

Output fields

FieldTypeDescription
_sendmail_failstringError reason if the email failed to send. This field is not set when delivery succeeds.

Error codes

Parsing errors
Error codeMessageDescription
31100No SMTP configuration for sendmail.The system SMTP configuration has not been set up.
31101sendmail command requires administrator permission.A user without administrator privileges attempted to run the command.
Runtime errors

N/A

Description

The sendmail command sends one email per input record. It reads the to, subject, and message fields from each record to construct the recipient, subject, and body. If cc and bcc fields are present, they are added as CC and BCC recipients.

If a required field (to, subject, message) is missing, or if an email address lacks a domain part (@), the email is not sent and the error reason is written to the _sendmail_fail field. If the mail queue is full, queue full is written to the _sendmail_fail field.

Regardless of whether delivery succeeds, the input record is passed to the next command unchanged.

Because the command requires a system SMTP configuration, you must first configure the SMTP server in the system settings of the web console.

Examples

  1. Send a plain-text email

    json "[{'to': 'admin@example.com', 'subject': 'Alert', 'message': 'Disk usage exceeded 90%'}]"
    | sendmail
    

    Sends a plain-text email using the to, subject, and message fields.

  2. Send an HTML email

    json "[{'to': 'admin@example.com', 'subject': 'Report', 'message': '<h1>Daily Report</h1><p>Total events: 1024</p>'}]"
    | sendmail html=t
    

    Sends the email body in HTML format using the html=t option.

  3. Send with CC and BCC

    json "[{'to': 'admin@example.com', 'cc': 'manager@example.com', 'bcc': 'audit@example.com', 'subject': 'Security Alert', 'message': 'Unauthorized access detected'}]"
    | sendmail
    

    Sends the email simultaneously to CC and BCC recipients along with the primary recipient.