POP3 Server with Explicit security mode

Explicit connection and Implicit connection are two secure methods to connect to a secure SMTP/POP3/POP3 server. This topic will go in detail the Explicit connection.

Explicit connection

When the client connects to the server using SSL, an SSL negotiation is initialized, the connection is secured and all following comminuation is being protected.

The code snippet below shows how to connect to an POP3 server securely using Explicit security mode.

C#:

// Create a new instance of the Pop3Client class.
Pop3Client client = new Pop3Client();
// Connect to the server.
client.Connect("myserver", 143, SecurityMode.Explicit);
// Login to the server.
client.Authenticate("user", "password");
StringBuilder sb = new StringBuilder();
Pop3MessageCollection list = client.ListMessages(EnvelopeParts.Size | EnvelopeParts.UniqueId);
for (int i = 0; i < list.Count; i++)
{
   sb.AppendFormat("{0} - {1}\r\n", i + 1, list[i].UniqueId);
}
Console.WriteLine(sb.ToString());
// Close the connection.
client.Disconnect();

VB.NET:

' Create a new instance of the Pop3Client class.
Dim client As New Pop3Client()
' Connect to the server.
client.Connect("myserver", 143, SecurityMode.Explicit)
' Login to the server.
client.Authenticate("user", "password")
Dim sb As New StringBuilder()
Dim list As Pop3MessageCollection = client.ListMessages(EnvelopeParts.Size Or EnvelopeParts.UniqueId)
For i As Integer = 0 To list.Count - 1
    sb.AppendFormat("{0} - {1}" & Constants.vbCrLf, i + 1, list(i).UniqueId)
Next i
Console.WriteLine(sb.ToString())
' Close the connection.
client.Disconnect()