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 when port is 465, false otherwise.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.
| 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 | Comma-separated list of allowed sender addresses. If set, only these addresses (and the default sender) can be used as the from field. Leave empty to allow only the default sender. |
| 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 | Enable SSL/TLS. Automatically set to true when port is 465, false otherwise. |
| 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:
froms list or be the default sender.| 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.
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.
The SMTP driver verifies the connection to the SMTP server at startup and periodically (every hour). If the verification fails, the driver restarts to re-establish the connection.
When sending fails, the driver automatically retries up to 5 times with a 500ms delay between attempts before reporting an error.
| Property | Value |
|---|---|
| Address regex | RFC email format: [from:]to[,to2][:subject] |
| Readable | No |
| Writable | Yes (validated against froms whitelist if configured) |
| Auto-creation | Yes — writing to a new email address auto-creates it |
String — used as plain text email body:
writeValue('admin@company.com', 'Temperature alert: 35°C')
Object — full Nodemailer mail options:
writeValue('admin@company.com:Alert', {
subject: 'Custom Subject',
text: 'Plain text body',
html: '<h1>HTML body</h1>'
})
File attachment — pass an address reference with name and gateway_id:
writeValue('admin@company.com', {
name: '%ftp/report.csv',
gateway_id: 5,
destinationOptions: { filename: 'report.csv', text: 'See attached report' }
})
secure: true