Skip to content

Commit

Permalink
[Email] Add documentation describing SSL port 465
Browse files Browse the repository at this point in the history
  • Loading branch information
TD-er committed Oct 7, 2024
1 parent 67dbb12 commit f5eabb4
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 27 deletions.
62 changes: 47 additions & 15 deletions docs/source/Notify/N001.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,64 @@ From the *Notifications* page, press *Edit* on an available *Nr* option. Next, C
.. image:: NotifyEmail2.png
:alt: Email Configuration Example

* **Domain :** Mail provider domain.
* **Server :** Mail server address (DNS or IP number). Must support non-secure SMTP.
* **Port :** Server port number. TLS / SSL ports are NOT supported.
* **Timeout :** Maximum allowed time for server reply. Increase value if server timeouts occur.
* **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.
* **User :** Server user name.
* **Pass :** Server password.
* **Body :** Message text. System variables allowed. Use <br> for new line. Maximum 512 characters.
* 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 :ref:`adv_feat` 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 <https://support.google.com/accounts/answer/185833?hl=en>`_ .

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
--------------------------
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.
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 ESPEasy's email is **not** directly compatible with popular providers such as gmail.com, yahoo.com, aol.com, and many others.
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.

But there are two workarounds for the SSL issue, as follows:
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).
Expand Down
Binary file modified docs/source/Notify/NotifyEmail2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/_N001_Email.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ bool NPlugin_001(NPlugin::Function function, struct EventStruct *event, String&
MakeNotificationSettings(NotificationSettings);
LoadNotificationSettings(event->NotificationIndex, (uint8_t *)&NotificationSettings, sizeof(NotificationSettingsStruct));
NotificationSettings.validate();

String subject = NotificationSettings.Subject;
String body = NotificationSettings.Body;

Expand Down
35 changes: 23 additions & 12 deletions src/src/WebServer/NotificationPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ void handle_notifications() {
strncpy_webserver_arg(NotificationSettings.User, F("username"));
strncpy_webserver_arg(NotificationSettings.Pass, F("password"));
strncpy_webserver_arg(NotificationSettings.Body, F("body"));
// copyFormPassword(F("password"), NotificationSettings.Pass, sizeof(NotificationSettings.Pass));

// copyFormPassword(F("password"), NotificationSettings.Pass, sizeof(NotificationSettings.Pass));
}
}
addHtmlError(SaveNotificationSettings(notificationindex, reinterpret_cast<const uint8_t *>(&NotificationSettings),
Expand Down Expand Up @@ -218,6 +219,14 @@ void handle_notifications() {
{
if (Notification[NotificationProtocolIndex].usesMessaging)
{
if (NotificationSettings.Port == 0) {
# if FEATURE_EMAIL_TLS
NotificationSettings.Port = 465;
# else // if FEATURE_EMAIL_TLS
NotificationSettings.Port = 25;
# endif // if FEATURE_EMAIL_TLS
}

addFormSubHeader(F("SMTP Server Settings"));
addFormTextBox(F("Domain"), F("domain"), NotificationSettings.Domain, sizeof(NotificationSettings.Domain) - 1);
addFormTextBox(F("Server"), F("server"), NotificationSettings.Server, sizeof(NotificationSettings.Server) - 1);
Expand All @@ -226,11 +235,11 @@ void handle_notifications() {
NotificationSettings.Port,
1,
65535);
#if FEATURE_EMAIL_TLS
addFormNote(F("default port SSL: 465, TLS: 587"));
#else
addFormNote(F("SSL/TLS servers NOT supported!"));
#endif
# if FEATURE_EMAIL_TLS
addFormNote(F("default port SSL: 465"));
# else // if FEATURE_EMAIL_TLS
addFormNote(F("default port: 25, SSL/TLS servers NOT supported!"));
# endif // if FEATURE_EMAIL_TLS

if ((NotificationSettings.Timeout_ms < NPLUGIN_001_MIN_TM) ||
(NotificationSettings.Timeout_ms > NPLUGIN_001_MAX_TM))
Expand All @@ -254,15 +263,17 @@ void handle_notifications() {
ZERO_TERMINATE(NotificationSettings.Pass);
addFormSubHeader(F("Credentials"));

addFormTextBox(F("Username"), F("username"), NotificationSettings.User, sizeof(NotificationSettings.User) - 1);
addFormTextBox(F("Password"), F("password"), NotificationSettings.Pass, sizeof(NotificationSettings.Pass) - 1);
// addFormPasswordBox(F("Password"), F("password"), NotificationSettings.Pass, sizeof(NotificationSettings.Pass) - 1);
addFormTextBox(F("Username"), F("username"), NotificationSettings.User, sizeof(NotificationSettings.User) - 1);
addFormTextBox(F("Password"), F("password"), NotificationSettings.Pass, sizeof(NotificationSettings.Pass) - 1);

// addFormPasswordBox(F("Password"), F("password"), NotificationSettings.Pass, sizeof(NotificationSettings.Pass) -
// 1);

addFormSubHeader(F("Email Attributes"));

addFormTextBox(F("Sender"), F("sender"), NotificationSettings.Sender, sizeof(NotificationSettings.Sender) - 1);
addFormTextBox(F("Receiver"), F("receiver"), NotificationSettings.Receiver, sizeof(NotificationSettings.Receiver) - 1);
addFormTextBox(F("Subject"), F("subject"), NotificationSettings.Subject, sizeof(NotificationSettings.Subject) - 1);
addFormTextBox(F("Sender"), F("sender"), NotificationSettings.Sender, sizeof(NotificationSettings.Sender) - 1);
addFormTextBox(F("Receiver"), F("receiver"), NotificationSettings.Receiver, sizeof(NotificationSettings.Receiver) - 1);
addFormTextBox(F("Subject"), F("subject"), NotificationSettings.Subject, sizeof(NotificationSettings.Subject) - 1);

addRowLabel(F("Body"));
addHtml(F("<textarea name='body' rows='20' size=512 wrap='off'>"));
Expand Down

0 comments on commit f5eabb4

Please sign in to comment.