mail

Function

ArgDescriptionType
toRecipient of the maillist of string (required)
fromThe from email address.string
ccA cc for the maillist of string
subjectThe subject.string
bodyThe body of the mail.string (required)
periodHow long to wait before sending the next mail - help to throttle mails.int64
server_portThe SMTP server port to use (default 587).uint64
serverThe SMTP server to use (if not specified we try the config file).string
auth_usernameThe SMTP username we authenticate to the server.string
auth_passwordThe SMTP username password we use to authenticate to the server.string
skip_verifySkip SSL verification(default: False).bool
root_caAs a better alternative to disable_ssl_security, allows root ca certs to be added here.string
secretAlternatively use a secret from the secrets service. Secret must be of type ‘SMTP Creds’string
headersA dict of headers to send.ordereddict.Dict

Required permissions:SERVER_ADMIN

Description

Send Email to a remote server.

This function will send an email to a remote SMTP server. The mail will be sent using SMTP with TLS and authentication.

Mails will be globally rate limited (among all queries) to the specified period (default 60 seconds) to prevent overloading the SMTP server. For this reason it is not suitable as a way to send high number of events - use it sparingly to notify on some rare events.

You can either fill in the auth_username and auth_password parameters directly or use the secrets service to encapsulate secrets in a managed way.

You can set any headers needed - for example to send HTML email set the Content-Type to “text/html”

Example

SELECT mail(secret="gmail",
            subject="Hello from Velociraptor",
            to="user@example.com",
            headers=dict(`Content-Type`="text/html"),
            body="<h1>Good morning</h1><p>From Velociraptor")
FROM scope()