SMTP (Simple Mail Transfer Protocol) is a standard protocol used for sending email messages over the internet. The Weble universal gateway SMTP driver acts as an email client that connects to an SMTP server to send emails triggered by the gateway — typically for alerts, notifications, and automated reports.
The driver uses Nodemailer under the hood and supports:
A common use case is to send alarm emails when sensor values exceed thresholds. For example, a route can monitor a temperature sensor (via Modbus, BACnet, or Zigbee) and write to an SMTP address whenever the temperature goes above a critical value — the gateway then sends the alert email automatically.
Create a new gateway and select the SMTP client driver. Configure the SMTP server connection:
smtp.gmail.com, smtp.office365.com).465 for SSL/TLS (recommended) or 587 for STARTTLS.true on 465, false otherwise); see 3.6 Notes and limits.Optionally configure:
Once the gateway is started, it verifies the connection to the SMTP server. To send an email, simply insert an address with the recipient's email address as the name:
recipient@example.com.The email is sent immediately with the default sender and default subject.
The SMTP driver is typically used as a destination in routes. For example:
See the article Email gateway status alerts for a concrete example. From a logic circuit, send the e-mail with a Write gate whose target is the SMTP address.
| Label | JSON Key | Description |
|---|---|---|
| Name | name | A descriptive name for this SMTP gateway instance. |
| Cluster ID | cluster | Cluster identifier (integer). Use 0 for single-gateway setups. |
| Description | description | Optional description for this gateway. |
| DefaultSubject | defaultSubject | Default email subject used when no subject is specified in the address name. |
| DefaultFrom | defaultFrom | Default sender email address. If left empty, the SMTP authentication username is used as the sender. |
| Froms | froms | Whitelist of sender addresses, separated by commas or semicolons. When set, a write that creates a new address is refused unless the sender given in the address name is the default sender or one of the listed addresses. Leave empty to allow any sender (the SMTP server may still reject a sender it does not own). Froms is not an access control: only give write access to SMTP addresses to trusted accounts and routes. |
| Label | JSON Key | Description |
|---|---|---|
| Host | smtp.host | SMTP server hostname or IP address (e.g. smtp.gmail.com). |
| Port | smtp.port | SMTP server port: 465 (SSL/TLS, recommended) or 587 (STARTTLS). |
| Secure | smtp.secure | Shown for information. The driver sets it automatically at each start: true on port 465 (implicit TLS), false on any other port (STARTTLS is used when the server offers it). |
| Username | smtp.auth.user | SMTP authentication username (usually the email address). |
| Password | smtp.auth.pass | SMTP authentication password. Leave both username and password empty if the server does not require authentication. |
{
"smtp": {
"host": "smtp.gmail.com",
"port": 465,
"secure": true,
"auth": {
"user": "alerts@mycompany.com",
"pass": "app-specific-password"
}
},
"defaultSubject": "Gateway Alert",
"defaultFrom": "alerts@mycompany.com",
"froms": ""
}
Multiple allowed senders:
{
"smtp": {
"host": "mail.example.com",
"port": 587,
"secure": false,
"auth": {
"user": "noreply@example.com",
"pass": "password123"
}
},
"defaultSubject": "IoT Notification",
"defaultFrom": "noreply@example.com",
"froms": "alerts@example.com,reports@example.com"
}
SMTP addresses encode the recipient, and optionally the sender and subject, in the address name:
[from:]to[:subject]
Where:
| Address | Sender | Recipient(s) | Subject |
|---|---|---|---|
user@example.com |
default | user@example.com | default |
user@example.com:Alert! |
default | user@example.com | Alert! |
sender@co.com:user@example.com |
sender@co.com | user@example.com | default |
sender@co.com:a@co.com,b@co.com:Wind Alert |
sender@co.com | a@co.com, b@co.com | Wind Alert |
The address form in the UI provides two fields — Email (the recipient) and Subject — to simplify address creation. The addresses are displayed in a tree grouped by recipient and subject.
| Label | JSON Key | Description |
|---|---|---|
| Name | name | The email address in the format described above. |
| Description | description | Optional description for this address. |
| Log | log | Logging mode: never, on update, always, or a duration in milliseconds. |
Writing a value to an SMTP address triggers an email. The value can be:
Simple text — the value is used as the email body:
"The temperature in Room 1 has exceeded 30°C."
JSON object — allows setting additional email options (any Nodemailer message option):
{
"subject": "Custom Subject",
"text": "Plain text body",
"html": "<h1>HTML body</h1><p>With <b>formatting</b></p>"
}
Files from other drivers can be sent as email attachments using the streaming API. When writing a value that contains a name and gateway_id, the SMTP driver interprets it as a file stream reference and attaches the file to the email.
This is typically used in combination with the CSV driver or the FTP driver to send generated files as email attachments.
{
"name": "<address of the file in the source gateway>",
"gateway_id": 5,
"destinationOptions": { "filename": "report.csv", "text": "See attached report" }
}
text.If an email is sent to an address that does not yet exist in the gateway, the address is automatically created. This means you can write to any valid email address format without having to manually create it first.
465.DefaultFrom must be a valid e-mail address. If it is empty, the SMTP Username is used as sender, but only when the username is itself an e-mail address. With providers whose login is not an address (API key, account ID…), always fill in DefaultFrom.:, ;, @ or ^. For such subjects (for example Re: alarm), write an object value with a subject property instead.smtp object of the gateway JSON is passed as is to Nodemailer, so options that are not in the form — for example "tls": { "rejectUnauthorized": false } for a server with a self-signed certificate, or "requireTLS": true — can be added through the API. See the Nodemailer SMTP options.missing license.destinationOptions.filename the attachment is named defaultAttachementName; without any text the body is <no text>.smtp.example.com, port 465, DefaultSubject home automation.| Property | Value |
|---|---|
| Readable | No |
| Writable | Yes — each write sends an e-mail. When Froms is set, the sender of a new address must be the default sender or a listed one. |
| Routable | Yes |
| Loggable | Yes |
| Auto-creation | Yes (see 3.5) |
The driver verifies the connection to the SMTP server when it starts, again one hour after the last e-mail was sent (or one hour after start-up if nothing was sent), and after a send that failed all its retries. If the verification fails, the driver restarts and the gateway reconnects.
When sending fails, the driver automatically retries up to 5 times with a 500ms delay between attempts before reporting an error.
| Symptom | Cause | What to do |
|---|---|---|
The gateway restarts in a loop; the log shows could not verify transporter ... |
Wrong Host or Port, wrong credentials, or the server cannot be reached. | Check the settings with your e-mail provider; use port 465 for implicit TLS or 587 for STARTTLS (section 3.6). |
The gateway does not start; the log shows invalid config: json.smtp is missing |
The SMTP connection was never filled in. | Fill in Host and Port. |
A write fails after 5 tries; the log shows failed to send email |
The server refused the message: sender not allowed, recipient refused, quota. | Read the error in the log. Fill in DefaultFrom with an address the account may send from (section 3.6). |
| A write to a new address is refused | Froms is set and the sender of the address is not in the list. | Use the default sender or add the sender to Froms. |
A subject needs :, ;, @ or ^ |
These characters cannot be used in the subject part of the address name. | Write an object value with a subject property (section 3.3). |
The log shows missing license |
No SMTP licence. | Contact support@weble.ch. |
To read the driver log, open the menu ☰ of the gateway and choose Logs (see Logs of a gateway).