E-Mail (SMTP Client)
The SMTP Client feature lets your device send email through an outgoing mail server. Use it for alarms, daily reports, or any notification that should reach a person directly.
The feature holds the server connection details. Messages are sent with the Send Email block, which only sets the recipient, subject and body.
Configuration
General
- SMTP Client Enabled: turns the client on. All other properties are disabled while it is off.
- SMTP Server: hostname or IP address of the outgoing mail server, for example
smtp.gmail.com. - Port: TCP port of the server. Defaults to
465. - Connection Security: how the connection is protected.
- None: plain, unencrypted connection (typically port
25). - STARTTLS: starts plain and upgrades to TLS (typically port
587). - SSL/TLS: TLS from the first byte (typically port
465). This is the default.
- None: plain, unencrypted connection (typically port
- From Address: the address messages are sent from. It is used as both the envelope sender and the
From:header.
Authentication
- Authentication Method:
None,PLAIN, orLOGIN(default). Choose None for servers that do not require a login. - Username: account name used to log in, often the full email address.
- Password: account password. Many providers require an app-specific password instead of your normal password.
The username and password are disabled when the method is None.
Advanced
- Timeout (ms): how long to wait for the server to answer a command before the send fails. Defaults to
10000. - Log Level: verbosity of the client's log output, from
NonetoDebug.
Linking to Settings
SMTP Server, Port, From Address, Username and Password can be linked to settings. This lets each installed device use its own mail account, configured from the Web Console, without rebuilding the firmware.
Dependencies
The feature automatically adds the socket and DNS libraries to the project. When Connection Security is anything other than None, the MbedTLS library is added as well.
Common Providers
| Provider | Server | Port | Security |
|---|---|---|---|
| Gmail | smtp.gmail.com | 465 | SSL/TLS |
| Outlook / Microsoft 365 | smtp.office365.com | 587 | STARTTLS |
Check your provider's documentation for current values. Most providers also require an app password or an explicit setting to allow SMTP access.
Related Blocks
- Send Email: sends a message through this feature.