Skip to content

Commit

Permalink
Add a define to force disable SSL #31
Browse files Browse the repository at this point in the history
  • Loading branch information
xreef committed Aug 16, 2022
1 parent 6afd5ab commit 2a8d4b2
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 33 deletions.
55 changes: 28 additions & 27 deletions EMailSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* EMail Sender Arduino, esp8266, stm32 and esp32 library to send email
*
* AUTHOR: Renzo Mischianti
* VERSION: 3.0.5
* VERSION: 3.0.6
*
* https://www.mischianti.org/
*
Expand Down Expand Up @@ -468,33 +468,34 @@ EMailSender::Response EMailSender::send(const char* to[], byte sizeOfTo, byte s

DEBUG_PRINT(F("Insecure client:"));
DEBUG_PRINTLN(this->isSecure);

#if (EMAIL_NETWORK_TYPE == NETWORK_ESP8266 || EMAIL_NETWORK_TYPE == NETWORK_ESP8266_242)
#ifndef ARDUINO_ESP8266_RELEASE_2_4_2
if (this->isSecure == false){
client.setInsecure();
bool mfln = client.probeMaxFragmentLength(this->smtp_server, this->smtp_port, 512);

DEBUG_PRINT("MFLN supported: ");
DEBUG_PRINTLN(mfln?"yes":"no");

if (mfln) {
client.setBufferSizes(512, 512);
#ifndef FORCE_DISABLE_SSL
#if (EMAIL_NETWORK_TYPE == NETWORK_ESP8266 || EMAIL_NETWORK_TYPE == NETWORK_ESP8266_242)
#ifndef ARDUINO_ESP8266_RELEASE_2_4_2
if (this->isSecure == false){
client.setInsecure();
bool mfln = client.probeMaxFragmentLength(this->smtp_server, this->smtp_port, 512);

DEBUG_PRINT("MFLN supported: ");
DEBUG_PRINTLN(mfln?"yes":"no");

if (mfln) {
client.setBufferSizes(512, 512);
}
}
}
#endif
#elif (EMAIL_NETWORK_TYPE == NETWORK_ESP32)
// String coreVersion = String(ESP.getSdkVersion());
// uint8_t firstdot = coreVersion.indexOf('.');
//
// DEBUG_PRINTLN(coreVersion.substring(1, coreVersion.indexOf('.', firstdot+1)).toFloat());
// DEBUG_PRINTLN(coreVersion.substring(1, coreVersion.indexOf('.', firstdot+1)).toFloat() >= 3.3f);
// if (coreVersion.substring(1, coreVersion.indexOf('.', firstdot+1)).toFloat() >= 3.3f) {
// client.setInsecure();
// }
#include <core_version.h>
#if ((!defined(ARDUINO_ESP32_RELEASE_1_0_4)) && (!defined(ARDUINO_ESP32_RELEASE_1_0_3)) && (!defined(ARDUINO_ESP32_RELEASE_1_0_2)))
client.setInsecure();
#endif
#elif (EMAIL_NETWORK_TYPE == NETWORK_ESP32)
// String coreVersion = String(ESP.getSdkVersion());
// uint8_t firstdot = coreVersion.indexOf('.');
//
// DEBUG_PRINTLN(coreVersion.substring(1, coreVersion.indexOf('.', firstdot+1)).toFloat());
// DEBUG_PRINTLN(coreVersion.substring(1, coreVersion.indexOf('.', firstdot+1)).toFloat() >= 3.3f);
// if (coreVersion.substring(1, coreVersion.indexOf('.', firstdot+1)).toFloat() >= 3.3f) {
// client.setInsecure();
// }
#include <core_version.h>
#if ((!defined(ARDUINO_ESP32_RELEASE_1_0_4)) && (!defined(ARDUINO_ESP32_RELEASE_1_0_3)) && (!defined(ARDUINO_ESP32_RELEASE_1_0_2)))
client.setInsecure();
#endif
#endif
#endif
#endif
Expand Down
8 changes: 5 additions & 3 deletions EMailSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* EMail Sender Arduino, esp8266, stm32 and esp32 library to send email
*
* AUTHOR: Renzo Mischianti
* VERSION: 3.0.5
* VERSION: 3.0.6
*
* https://www.mischianti.org/
*
Expand Down Expand Up @@ -213,7 +213,7 @@
#elif(EMAIL_NETWORK_TYPE == NETWORK_WiFiNINA)

#include <WiFiNINA.h>
//#define EMAIL_NETWORK_CLASS WiFiSSLClient
#define EMAIL_NETWORK_CLASS WiFiClient
#define EMAIL_NETWORK_SSL_CLASS WiFiSSLClient
#define EMAIL_NETWORK_SERVER_CLASS WiFiServer

Expand Down Expand Up @@ -298,7 +298,9 @@
#endif

#ifdef EMAIL_NETWORK_SSL_CLASS
#define EMAIL_NETWORK_CLASS EMAIL_NETWORK_SSL_CLASS
#ifndef FORCE_DISABLE_SSL
#define EMAIL_NETWORK_CLASS EMAIL_NETWORK_SSL_CLASS
#endif
#endif

#define OPEN_CLOSE_INTERNAL
Expand Down
7 changes: 6 additions & 1 deletion EMailSenderKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* EMail Sender Arduino, esp8266, stm32 and esp32 library to send email
*
* AUTHOR: Renzo Mischianti
* VERSION: 3.0.5
* VERSION: 3.0.6
*
* https://www.mischianti.org/
*
Expand Down Expand Up @@ -37,6 +37,7 @@
// Uncomment if you use esp8266 core <= 2.4.2
//#define ARDUINO_ESP8266_RELEASE_2_4_2

// If you want disable attachments and save memory comment this define
#define ENABLE_ATTACHMENTS

// Uncomment to enable printing out nice debug messages.
Expand Down Expand Up @@ -69,6 +70,10 @@
#define NETWORK_UIPETHERNET (11)
#define NETWORK_ETHERNET_2 (12)

// if you want force disable SSL if present uncomment this define
// #define FORCE_DISABLE_SSL

// If you want add a wrapper to emulate SSL over Client like EthernetClient
// #define SSLCLIENT_WRAPPER

// esp8266 microcontrollers configuration
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Arduino (support W5100 like must be set, and ENC28J60 via UIPEthernet), esp8266
#### [Inviare email con allegati (libreria v2.x): esp32 e esp8266](https://www.mischianti.org/it/2020/06/16/inviare-email-con-allegati-libreria-v2-x-esp32-e-esp8266-part-2/)

## Change log
- 16/08/2022: v3.0.6 Add FORCE_DISABLE_SSL to disable SSL if present
- 19/07/2022: v3.0.5 Additional fix on additional response management ([#26](https://github.com/xreef/EMailSender/issues/26))
- 12/07/2022: v3.0.4 Fixed attachment issue on SPIFFS and LittleFS
- 06/07/2022: v3.0.3 Manage multiple response message after connect and HELO ([#26](https://github.com/xreef/EMailSender/issues/26))
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
},
"url": "https://www.mischianti.org",
"frameworks": "Arduino",
"version": "3.0.5",
"version": "3.0.6",
"platforms": "*"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=EMailSender
version=3.0.5
version=3.0.6
author=Renzo Mischianti <[email protected]>
maintainer=Renzo Mischianti <[email protected]>
sentence=Send EMail via SMTP, library for Arduino, SAMD (WiFiNINA), STM32, esp8266 and esp32.
Expand Down

0 comments on commit 2a8d4b2

Please sign in to comment.