How to send email with SMTP

Knock supports sending email notifications to your users via the Simple Mail Transfer Protocol (SMTP). In this configuration, Knock will act as an SMTP client and send email notifications to a specified SMTP server.

In this guide, we'll cover how to get started sending email notifications using SMTP with Knock.

Features

  • Attachments support
  • Link and open tracking
  • Per environment configuration
  • Sandbox mode

Getting started

You can create a new SMTP Relay channel in the dashboard under the Integrations > Channels section. From there, you'll need to configure the channel for each environment you have.

The following information is required to configure an SMTP Relay channel:

  • SMTP server host
  • SMTP server port
  • Username
  • Password

Please note the following:

  • Knock only supports authenticated SMTP connections.
  • The port must support TLS. Email providers commonly use port 587 for TLS, but check your provider's documentation to confirm.
  • We cannot currently track deliverability through SMTP Relay channels. This means that all notifications sent via SMTP will show up as "Sent" in the Knock messages log, but not "Delivered."

Provider configuration

Hoststring*The SMTP server host
Usernamestring*The username to use when authenticating with the SMTP server
Passwordstring*The password to use when authenticating with the SMTP server
PortnumberThe SMTP server port. This port must support TLS.

Environment default settings

The following fields are optional and, if set, will be applied to all email messages sent via this channel within the environment:

Reply-to addressstring | liquidThe reply-to email address (can use Liquid tags)
CC addressstring | liquidThe cc email address (can use Liquid tags)
BCC addressstring | liquidThe bcc email address (can use Liquid tags)
JSON overridesstring | liquidSMTP header overrides
🌠
JSON overrides behavior. For SMTP Relay channels, only header overrides are supported. See Setting SMTP headers for more details.

Setting SMTP headers

For SMTP Relay channels, the JSON overrides field can be used to set SMTP headers. Overrides can be set in either the environment settings or per template.

Knock supports overriding existing SMTP headers and adding custom headers.

Headers must be nested under the headers key. Other keys will be ignored.

🔦
SMTP headers are sent as strings. If one of your header overrides is not already a string, Knock will automatically convert it to a string before sending.

Recipient data requirements

In order to send an email notification you'll need a valid email property set on your recipient.