Skip to content

Commit

Permalink
Add support SSL session resumption for SSL handshake.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Sep 13, 2023
1 parent 0c99b83 commit 74e45c6
Show file tree
Hide file tree
Showing 60 changed files with 659 additions and 404 deletions.
21 changes: 12 additions & 9 deletions examples/IMAP/ACL/ACL.ino
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,15 @@ void setup()

/* Connect to the server */
if (!imap.connect(&config, &imap_data))
{
MailClient.printf("Connection error, Error Code: %d, Reason: %s\n", imap.errorCode(), imap.errorReason().c_str());
return;
}

if (imap.isAuthenticated())
Serial.println("\nSuccessfully logged in.");
Serial.println("Successfully logged in.");
else
Serial.println("\nConnected with no Auth.");
Serial.println("Connected with no Auth.");

IMAP_Rights_List acl_list;

Expand Down Expand Up @@ -229,14 +232,14 @@ void setup()
{
Serial.print("Rights: ");

String r;
for (int i = esp_mail_imap_rights_administer; i < esp_mail_imap_rights_maxType; i++)
{
if (acl.rights[i])
r += (char)('a' + i);
}
String r;
for (int i = esp_mail_imap_rights_administer; i < esp_mail_imap_rights_maxType; i++)
{
if (acl.rights[i])
r += (char)('a' + i);
}

Serial.println(r);
Serial.println(r);
}

Serial.println("\nDelete ACLs...");
Expand Down
17 changes: 10 additions & 7 deletions examples/IMAP/Append_Message/Append_Message.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* Github: https://github.com/mobizt/ESP-Mail-Client
*
* Copyright (c) 2023 mobizt
*/
*/

// This example shows how to append message to mailbox.

/** Note for library update from v2.x.x to v3.x.x.
*
*
* Struct data names changed
*
* "ESP_Mail_Session" changes to "Session_Config"
Expand Down Expand Up @@ -121,7 +121,7 @@ void setup()
#endif

Serial.print("Connecting to Wi-Fi");

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
unsigned long ms = millis();
#endif
Expand Down Expand Up @@ -210,12 +210,15 @@ void setup()

/* Connect to the server */
if (!imap.connect(&config, &imap_data))
{
MailClient.printf("Connection error, Error Code: %d, Reason: %s\n", imap.errorCode(), imap.errorReason().c_str());
return;
}

if (imap.isAuthenticated())
Serial.println("\nSuccessfully logged in.");
Serial.println("Successfully logged in.");
else
Serial.println("\nConnected with no Auth.");
Serial.println("Connected with no Auth.");

if (!imap.selectFolder(F("INBOX")))
return;
Expand All @@ -224,10 +227,10 @@ void setup()
// If not, one message can append for a APPEND command.
// Outlook.com does not accept flag and date/time arguments in APPEND command
if (!MailClient.appendMessage(&imap, &message[0], false /* if not last message to append */, "\\Flagged" /* flags or empty string for Outlook.com */, "Thu, 16 Jun 2022 12:30:25 -0800 (PST)" /* date/time or empty string for Outlook.com */))
MailClient.printf("Message appending error, Error Code: %d, Reason: %s", imap.errorCode(), imap.errorReason().c_str());
MailClient.printf("Message appending error, Error Code: %d, Reason: %s\n", imap.errorCode(), imap.errorReason().c_str());

if (!MailClient.appendMessage(&imap, &message[1], true /* last message to append */))
MailClient.printf("Message appending error, Error Code: %d, Reason: %s", imap.errorCode(), imap.errorReason().c_str());
MailClient.printf("Message appending error, Error Code: %d, Reason: %s\n", imap.errorCode(), imap.errorReason().c_str());

MailClient.printf("Free Heap: %d\n", MailClient.getFreeHeap());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* Github: https://github.com/mobizt/ESP-Mail-Client
*
* Copyright (c) 2023 mobizt
*/
*/

// This example shows how to copy messages from the mailbox to other folder.

/** Note for library update from v2.x.x to v3.x.x.
*
*
* Struct data names changed
*
* "ESP_Mail_Session" changes to "Session_Config"
Expand Down Expand Up @@ -111,7 +111,7 @@ void setup()
#endif

Serial.print("Connecting to Wi-Fi");

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
unsigned long ms = millis();
#endif
Expand Down Expand Up @@ -162,12 +162,15 @@ void setup()

/* Connect to the server */
if (!imap.connect(&config, &imap_data))
{
MailClient.printf("Connection error, Error Code: %d, Reason: %s\n", imap.errorCode(), imap.errorReason().c_str());
return;
}

if (imap.isAuthenticated())
Serial.println("\nSuccessfully logged in.");
Serial.println("Successfully logged in.");
else
Serial.println("\nConnected with no Auth.");
Serial.println("Connected with no Auth.");

/* {Optional} */
printAllMailboxesInfo(imap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* Github: https://github.com/mobizt/ESP-Mail-Client
*
* Copyright (c) 2023 mobizt
*/
*/

// This example shows how to copy messages from the mailbox to other folder using message numbers ranges.

/** Note for library update from v2.x.x to v3.x.x.
*
*
* Struct data names changed
*
* "ESP_Mail_Session" changes to "Session_Config"
Expand Down Expand Up @@ -111,7 +111,7 @@ void setup()
#endif

Serial.print("Connecting to Wi-Fi");

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
unsigned long ms = millis();
#endif
Expand Down Expand Up @@ -162,12 +162,15 @@ void setup()

/* Connect to the server */
if (!imap.connect(&config, &imap_data))
{
MailClient.printf("Connection error, Error Code: %d, Reason: %s\n", imap.errorCode(), imap.errorReason().c_str());
return;
}

if (imap.isAuthenticated())
Serial.println("\nSuccessfully logged in.");
Serial.println("Successfully logged in.");
else
Serial.println("\nConnected with no Auth.");
Serial.println("Connected with no Auth.");

/* {Optional} */
printAllMailboxesInfo(imap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* Github: https://github.com/mobizt/ESP-Mail-Client
*
* Copyright (c) 2023 mobizt
*/
*/

// This example shows how to copy messages from the mailbox to other folder using UIDs ranges.

/** Note for library update from v2.x.x to v3.x.x.
*
*
* Struct data names changed
*
* "ESP_Mail_Session" changes to "Session_Config"
Expand Down Expand Up @@ -111,7 +111,7 @@ void setup()
#endif

Serial.print("Connecting to Wi-Fi");

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
unsigned long ms = millis();
#endif
Expand Down Expand Up @@ -162,12 +162,15 @@ void setup()

/* Connect to the server */
if (!imap.connect(&config, &imap_data))
{
MailClient.printf("Connection error, Error Code: %d, Reason: %s\n", imap.errorCode(), imap.errorReason().c_str());
return;
}

if (imap.isAuthenticated())
Serial.println("\nSuccessfully logged in.");
Serial.println("Successfully logged in.");
else
Serial.println("\nConnected with no Auth.");
Serial.println("Connected with no Auth.");

/* {Optional} */
printAllMailboxesInfo(imap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,15 @@ void setup()

/* Connect to the server */
if (!imap.connect(&config, &imap_data))
{
MailClient.printf("Connection error, Error Code: %d, Reason: %s\n", imap.errorCode(), imap.errorReason().c_str());
return;
}

if (imap.isAuthenticated())
Serial.println("\nSuccessfully logged in.");
Serial.println("Successfully logged in.");
else
Serial.println("\nConnected with no Auth.");
Serial.println("Connected with no Auth.");

/* {Optional} */
printAllMailboxesInfo(imap);
Expand Down
13 changes: 8 additions & 5 deletions examples/IMAP/Custom_Command/Basic_Auth/Basic_Auth.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* Github: https://github.com/mobizt/ESP-Mail-Client
*
* Copyright (c) 2023 mobizt
*/
*/

// This example shows how to send custom IMAP command and get the response.

/** Note for library update from v2.x.x to v3.x.x.
*
*
* Struct data names changed
*
* "ESP_Mail_Session" changes to "Session_Config"
Expand Down Expand Up @@ -129,7 +129,7 @@ void setup()
#endif

Serial.print("Connecting to Wi-Fi");

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
unsigned long ms = millis();
#endif
Expand Down Expand Up @@ -175,12 +175,15 @@ void setup()

/* Connect to the server */
if (!imap.connect(&config, &imap_data))
{
MailClient.printf("Connection error, Error Code: %d, Reason: %s\n", imap.errorCode(), imap.errorReason().c_str());
return;
}

if (imap.isAuthenticated())
Serial.println("\nSuccessfully logged in.\n");
Serial.println("Successfully logged in.");
else
Serial.println("\nConnected with no Auth.\n");
Serial.println("Connected with no Auth.");

// You can also assign tag to the begining of the command e.g. "A01 FETCH 1 UID"
// Do not assign tag to command when you assign tag to the last parameter of function.
Expand Down
15 changes: 9 additions & 6 deletions examples/IMAP/Custom_Ports/Custom_Ports.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* Github: https://github.com/mobizt/ESP-Mail-Client
*
* Copyright (c) 2023 mobizt
*/
*/

// This example shows how to assign the custom ports with protocols to access IMAP server.

/** Note for library update from v2.x.x to v3.x.x.
*
*
* Struct data names changed
*
* "ESP_Mail_Session" changes to "Session_Config"
Expand Down Expand Up @@ -112,7 +112,7 @@ void setup()
#endif

Serial.print("Connecting to Wi-Fi");

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
unsigned long ms = millis();
#endif
Expand Down Expand Up @@ -187,12 +187,15 @@ void setup()

/* Connect to the server */
if (!imap.connect(&config, &imap_data))
{
MailClient.printf("Connection error, Error Code: %d, Reason: %s\n", imap.errorCode(), imap.errorReason().c_str());
return;
}

if (imap.isAuthenticated())
Serial.println("\nSuccessfully logged in.");
Serial.println("Successfully logged in.");
else
Serial.println("\nConnected with no Auth.");
Serial.println("Connected with no Auth.");

/* {Optional} */
printAllMailboxesInfo(imap);
Expand Down Expand Up @@ -242,7 +245,7 @@ void printSelectedMailboxInfo(SelectedFolderInfo sFolder)
MailClient.printf("First Unseen Message Number: %d\n", sFolder.unseenIndex());
else
MailClient.printf("Unseen Messages: No\n");

if (sFolder.modSeqSupported())
MailClient.printf("Highest Modification Sequence: %llu\n", sFolder.highestModSeq());
for (size_t i = 0; i < sFolder.flagCount(); i++)
Expand Down
13 changes: 8 additions & 5 deletions examples/IMAP/Data_Stream_Callback/Data_Stream_Callback.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* Github: https://github.com/mobizt/ESP-Mail-Client
*
* Copyright (c) 2023 mobizt
*/
*/

// This example shows how to read Email and collect the stream data to print or store via the callback function.

/** Note for library update from v2.x.x to v3.x.x.
*
*
* Struct data names changed
*
* "ESP_Mail_Session" changes to "Session_Config"
Expand Down Expand Up @@ -112,7 +112,7 @@ void setup()
#endif

Serial.print("Connecting to Wi-Fi");

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
unsigned long ms = millis();
#endif
Expand Down Expand Up @@ -226,12 +226,15 @@ void setup()

/* Connect to the server */
if (!imap.connect(&config, &imap_data))
{
MailClient.printf("Connection error, Error Code: %d, Reason: %s\n", imap.errorCode(), imap.errorReason().c_str());
return;
}

if (imap.isAuthenticated())
Serial.println("\nSuccessfully logged in.");
Serial.println("Successfully logged in.");
else
Serial.println("\nConnected with no Auth.");
Serial.println("Connected with no Auth.");

/* Open or select the mailbox folder to read or search the message */
if (!imap.selectFolder(F("INBOX")))
Expand Down
Loading

0 comments on commit 74e45c6

Please sign in to comment.