Skip to content

Commit

Permalink
Fix context management for backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
xreef committed May 20, 2022
1 parent 2bef4e5 commit f8e924f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 137 deletions.
22 changes: 10 additions & 12 deletions EMailSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,30 +443,28 @@ EMailSender::Response EMailSender::send(const char* to[], byte sizeOfTo, byte s
}

#ifdef SSLCLIENT_WRAPPER
#ifdef PUT_OUTSIDE_SCOPE_CLIENT_DECLARATION
// Initialize the SSL client library
// We input an EthernetClient, our trust anchors, and the analog pin
EMAIL_NETWORK_CLASS base_client;
SSLClient client(base_client, TAs, (size_t)TAs_NUM, ANALOG_PIN, 2);
#else
EMAIL_NETWORK_CLASS client;
#error "You must put outside scope the client declaration if you want use SSLClient!"
#endif
#else
#ifdef PUT_OUTSIDE_SCOPE_CLIENT_DECLARATION
EMAIL_NETWORK_CLASS client;
#endif
#endif

EMailSender::Response EMailSender::send(const char* to[], byte sizeOfTo, byte sizeOfCc,byte sizeOfCCn, EMailMessage &email, Attachments attachments)
{
#ifdef SSLCLIENT_WRAPPER
DEBUG_PRINTLN(F("SSLClient active!"));
// DEBUG_PRINTLN(F("Instantiate baseClient!"));
//delay(1000);
// EMAIL_NETWORK_CLASS baseClient;
// delay(1000);
// DEBUG_PRINTLN(F("Wrap baseClient!"));
// SSLClient client(baseClient, this->trust_anchors, (size_t)this->trust_anchors_num, this->analog_pin, this->max_sessions, SSLClient::SSL_DUMP);
//// SSLClient client(baseClient, TAs, (size_t)TAs_NUM, A7, 1, SSLClient::SSL_INFO);
//
// DEBUG_PRINTLN(F("Wraped baseClient!"));
#else
// EMAIL_NETWORK_CLASS client;
// SSLClient client(base_client, TAs, (size_t)TAs_NUM, A5);
#ifndef PUT_OUTSIDE_SCOPE_CLIENT_DECLARATION
EMAIL_NETWORK_CLASS client;
#endif

DEBUG_PRINT(F("Insecure client:"));
DEBUG_PRINTLN(this->isSecure);
Expand Down
2 changes: 2 additions & 0 deletions EMailSenderKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@
#define ANALOG_PIN A7
#include <SSLClient.h>
#include "trust_anchors.h"

#define PUT_OUTSIDE_SCOPE_CLIENT_DECLARATION
#endif

#define SD_CS_PIN SS
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
- 20/05/2022: v3.0.1 Put inside scope the client declaration (if you don't use SSLClient) for backward compatibility
- 18/05/2022: v3.0.0 Add STM32 support. Add SSLClient integration to allow send Email with SSL encryption (like Gmail) with ethernet (tested with STM32, ESP32, w5500, and enc28j60), minor fix
- 12/04/2021: v2.4.3 Fix multiple email send
- 12/04/2021: v2.4.1 Add support for LITTLEFS and Ffat on esp32 and fix certificate verification from esp32 core 1.0.5
Expand Down
124 changes: 0 additions & 124 deletions examples/Esp32GMailLITTLEFSAttachTest/Esp32GMailLITTLEFSAttachTest.ino

This file was deleted.

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.0
version=3.0.1
author=Renzo Mischianti <renzo.mischianti@gmail.com>
maintainer=Renzo Mischianti <renzo.mischianti@gmail.com>
sentence=Send EMail via SMTP, library for Arduino, SAMD (WiFiNINA), STM32, esp8266 and esp32.
Expand Down

0 comments on commit f8e924f

Please sign in to comment.