Notifications Email (SMTP)¶
Send the user a message using SMTP email. Multiple recipients are possible. IMPORTANT: Email server MUST allow a non-secure connection; The SSL/TLS SMTP protocol is not supported.
Type: Notifications
Name: Notifications Email (SMTP)
Status: NORMAL CLIMATE COLLECTION SONOFF SHELLY
GitHub: N001_Email.cpp
Maintainer: .
Used libraries: .
Introduction¶
Notifications Email (SMTP) is used to send an email message using ESPEasy rules.
Basic Rules Examples¶
The general syntax for sending an email is:
notify <Nr>
Where <Nr> is the position number (1,2,3) assigned to the notification declaration.
For example, to send your pre-defined email message after WiFi has connected, use a rule like this:
on WiFi#Connected do
notify 1
endon
To send an email every day at noon, create a rule like this:
on Clock#Time=All,12:00 do //will run once a day at noon
notify 1
endon
Hint
The examples discussed here have setup the Notification Email in the very first (Nr 1) row. So the command syntax will be “notify 1”
Email Configuration¶
ESPEasy’s Notifications tab allows up to three declarations for email (and buzzer) alerts.
The Notifications Email page is used to create pre-defined email messages. At least one is required to use the email feature.
From the Notifications page, press Edit on an available Nr option. Next, Choose Email (SMTP) in the drop-down list.
SMTP Server Settings
Domain : Mail provider domain.
Server : Mail server address (DNS or IP number). Must support non-secure SMTP.
Port : Server port number. (see note below)
Timeout : Maximum allowed time for server reply. Increase value if server timeouts occur.
Credentials
Username : Server user name.
Password : Server password.
Email Attributes
Sender : Sender’s email address (“From:”).
Receiver : Recipient’s email address (“To:”). Multiple allowed, use comma (,) between each address.
Subject : Text for email’s subject line.
Body : Message text. System variables allowed. Use <br> for new line. Maximum 512 characters.
Enabled : Check this box to enable the email feature.
Be sure to press Submit to save your settings.
Note: For more flexibility, there are Advanced Features within the notify command for changing the recipient(s), subject line, and message body.
Note
Whenever the email service allows to use temporary passwords, please use those to make sure your main password isn’t stored (unencrypted) on any ESPEasy device. For example, GMail allows to use App Passwords .
SSL Port¶
Added: 2024-10-07
Only ESP32-xx builds will have SSL support for sending emails. ESP8266 simply doesn’t have enough free memory available to setup a SSL connection.
Only SSL port 465 is supported, as for using port 587 (typically named “TLS”) extra steps are required to make a connection. This may be added later. |
Email Server Requirements with SSL¶
For ESP32-builds made after 2024-10-07, it is possible to use SSL (port 465) to connect to a mail server. Make sure the mail-server supports this port as the alternative on port 587 is not yet supported.
Not all hosting providers support this port as it is considered ‘deprecated’. However large mail providers like GMail, AOL and others still support this port.
Email Server Requirements without SSL¶
ESPEasy doesn’t support the SSL protocol on ESP8266 Unfortunately most Email service providers ended support for non-secure SMTP (without TLS / SSL) several years ago. This means that for ESP8266 ESPEasy’s email is not directly compatible with popular providers such as gmail.com, yahoo.com, aol.com, and many others.
However, there are two workarounds for the SSL issue, as follows:
Operate a mail server inside your local network.
Use an SMTP Email account from a provider that still supports non-secure SMTP (e.g. SMTP2go.com, smart-mail.de). Services such as SMTP2go will act as an SSL bridge from a non-secure sender. Personal (non-commercial) accounts are available at no cost too.
The table below provides sample entries for smtp2go.com and smtp.smart-mail.de
Name |
Example 1 |
Example 2 |
Description |
---|---|---|---|
Domain: |
smtp2go.com |
smart-mail.de |
Mail provider domain. |
Server: |
mail.smtp2go.com |
smtp.smart-mail.de |
Mail server address. |
Port: |
2525 |
25 |
SMTP port recommended by provider. |
Sender: |
Sender’s email address. |
||
Receiver: |
Recipient’s email address. Note: Multiple allowed, use comma (,) between each address. |
||
Subject: |
Subject Text |
Subject Text |
Topic in email headline. |
User: |
ESP123 |
Username to the SMTP Server. |
|
Pass: |
secretepw001%% |
secretepw002$$ |
Password to the SMTP Server. |
Body: |
Device uptime is %uptime% mins.<br> Connected via WiFi %ssid%. |
512 characters max. Use <br> for new line. |
|
Enabled: |
Check Box |
Check Box |
Email is disabled if box unchecked. |
Advanced Features¶
Along with the pre-defined settings, it is possible to customized the email’s message body, subject line, and recipient(s), all from the Notify command rule. So ad-hoc emails are possible.
Hint
Use the latest ESPEasy build. Older releases do not support these advanced features.
Custom Message Body¶
The Basic syntax for a custom message body is:
notify <Nr>, "Your Custom Message Goes Here. System variables can be used too. Wrap this text in quotes."
So to specify a custom message with the Notify command, use a rule like this:
notify 1,"%sysname% is online.<br>Location: Office.<br>Local IP: %ip%.<br>WiFi Signal: %rssi%dBm."
Custom Message Body and Subject Line¶
To specify a custom message AND subject line, use a rule like this:
notify 1,"%sysname% is online.<br>Location: Office.<br>Local IP: %ip%.<br>WiFi Signal: %rssi%dBm.","Your Custom Subject Line Goes Here."
Custom Recipient Address¶
The custom message can also include the email recipient. The general syntax is:
notify <Nr>, "{email@domain.com},This is the email message. System variables can be used here."
For example:
notify 1,"{jimmydean@domain123.com},%sysname% has rebooted.<br>Local IP: %ip%.<br>WiFi Signal: %rssi%dBm.<br>Have a great day."
To include a custom subject with the previous example, simply add it as the last argument. Like this:
notify 1,"{jimmydean@domain123.com},%sysname% has rebooted.<br>Local IP: %ip%.<br>WiFi Signal: %rssi%dBm.<br>Have a great day.","System Reboot!"
Multiple email recipients can be specified too. Use a comma (,) between addresses.
notify 1,"{email123@domain.com,billy@steamhouseinc.com},The steam boiler is overheating!"
Attention
A custom message MUST be provided whenever the recipient address is specified in the Notify command. A custom subject line is optional.