User Authentication and SSL Connection


To logon POP3 or IMAP4 server, the user authentication is the first step. EAGetMail ActiveX Object supports most authentication mechanisms including: LOGIN, CRAM-MD5 and AUTH NTLM. The authentication mechanism must be specified by the following constants:

Const MailServerAuthLogin = 0
Const MailServerAuthCRAM5 = 1
Const MailServerAuthNTLM = 2	
Const MailServerAuthXOAUTH2 = 3	
		

The MailServerAuthCRAM5 and MailServerAuthNTLM are "Secure Password Authentication", the password is encrypted by challenge code returned by server before the password is sent to the server. In contrary, the password is sent to server in plain format with MailServerAuthLogin. Therefore, using MailServerAuthCRAM5 and MailServerAuthNTLM is more secure than using MailServerAuthLogin. However, not every mail server supports MailServerAuthCRAM5 and MailServerAuthNTLM. Especially MailServerAuthNTLM, only Microsoft Exchange Server or Windows POP3 Service supports it. Based on POP3/IMAP4 rfc, MailServerAuthLogin is supported by every POP3/IMAP4 server, so if you can't detect what authentication mechanisms that the server supports, please use MailServerAuthLogin.

Now most email servers use SSL/TLS + AuthLogin.

Example

[VBScript]
Const MailServerAuthLogin = 0
Const MailServerAuthCRAM5 = 1
Const MailServerAuthNTLM = 2
Const MailServerAuthXOAUTH2 = 3

Const MailServerPop3 = 0
Const MailServerImap4 = 1
Const MailServerEWS = 2
Const MailServerDAV = 3

Dim oServer
Set oServer = CreateObject("EAGetMailObj.MailServer")
oServer.Server = "myserveraddress"
oServer.User = "myuser"
oServer.Password = "mypassword"
oServer.SSLConnection = False
oServer.Protocol = MailServerPop3
oServer.AuthType = MailServerAuthLogin

SSL/TLS Connection

SSL connection encrypts data between the POP3 & IMAP4 component and mail server to protects user, password and email content in TCP/IP level. Now this technology is commonly used and many email servers are deployed with SSL such as gmail. The mail server usually deploys SSL on another port( POP3 on 995 or other port, IMAP4 on 993 or other port ), you may query it from your server administrator) directly. There are two ways to deploy SSL/TLS on POP3/IMAP4 server:

TLS 1.2 Encryption

TLS is the successor of SSL, EAGetMail supports SSL 3.0/TLS1.0 - 1.2 very well. In EAGetMail, ConnectTLS doesn't mean TLS encryption, it means TLS command POP3/IMAP protocol.

You don't have to set any property to enable TLS 1.2 encryption. If your server requires TLS 1.2 encryption, TLS 1.2 encryption is used automatically with ConnectTLS, ConnectSSL or ConnectSSLAuto.

To enable TLS 1.2 on some legacy systems, you have to install required update/packages:
Enable TLS 1.2 on Windows XP/2003/2008/7/2008 R2

Example

[Visual Basic 6 - SSL/TLS Setting]
Const MailServerAuthLogin = 0
Const MailServerAuthCRAM5 = 1
Const MailServerAuthNTLM = 2
Const MailServerAuthXOAUTH2 = 3

Const MailServerPop3 = 0
Const MailServerImap4 = 1
Const MailServerEWS = 2
Const MailServerDAV = 3

Const ConnectSSLAuto = 0
Const ConnectSSL = 1
Const ConnectTLS = 2

' Retrieve email by normal TCP/IP without SSL connection
' POP3
Dim oServer As New EAGetMailObjLib.MailServer
oServer.Server = "pop3.emailarchitect.net"
oServer.User = "test@emailarchitect.net"
oServer.Password = "testpassword"
oServer.Protocol = MailServerPop3
oServer.Port = 110

' IMAP4
Dim oServer As New EAGetMailObjLib.MailServer
oServer.Server = "imap4.emailarchitect.net"
oServer.User = "test@emailarchitect.net"
oServer.Password = "testpassword"
oServer.Protocol = MailServerImap4
oServer.Port = 143

' Exchange Web Service
Dim oServer As New EAGetMailObjLib.MailServer
oServer.Server = "exch.emailarchitect.net"
oServer.User = "emailarchitect.net\test"
oServer.Password = "testpassword"
oServer.Protocol = MailServerEWS

' Exchange WebDAV
Dim oServer As New EAGetMailObjLib.MailServer
oServer.Server = "exch.emailarchitect.net"
oServer.User = "emailarchitect.net\test"
oServer.Password = "testpassword"
oServer.Protocol = MailServerDAV

' Retrieve email over SSL connection with direct SSL.
' POP3 SSL
Dim oServer As New EAGetMailObjLib.MailServer
oServer.Server = "pop3.emailarchitect.net"
oServer.User = "test@emailarchitect.net"
oServer.Password = "testpassword"
oServer.Protocol = MailServerPop3
oServer.SSLConnection = True
oServer.Port = 995

' IMAP4 SSL
Dim oServer As New EAGetMailObjLib.MailServer
oServer.Server = "imap4.emailarchitect.net"
oServer.User = "test@emailarchitect.net"
oServer.Password = "testpassword"
oServer.Protocol = MailServerImap4
oServer.SSLConnection = True
oServer.Port = 993

' Retrieve email by SSL connection with STARTTLS or TLS command switching
' POP3 TLS
Dim oServer As New EAGetMailObjLib.MailServer
oServer.Server = "pop3.emailarchitect.net"
oServer.User = "test@emailarchitect.net"
oServer.Password = "testpassword"
oServer.Protocol = MailServerPop3
oServer.SSLConnection = True
oServer.Port = 110
oServer.SSLType = ConnectTLS

' IMAP4 STARTTLS
Dim oServer As New EAGetMailObjLib.MailServer
oServer.Server = "imap4.emailarchitect.net"
oServer.User = "test@emailarchitect.net"
oServer.Password = "testpassword"
oServer.Protocol = MailServerImap4
oServer.SSLConnection = True
oServer.Port = 143
oServer.SSLType = ConnectTLS


' Exchange Web Service SSL
Dim oServer As New EAGetMailObjLib.MailServer
oServer.Server = "exch.emailarchitect.net"
oServer.User = "emailarchitect.net\test"
oServer.Password = "testpassword"
oServer.Protocol = MailServerEWS
oServer.SSLConnection = True

' Exchange WebDAV SSL
Dim oServer As New EAGetMailObjLib.MailServer
oServer.Server = "exch.emailarchitect.net"
oServer.User = "emailarchitect.net\test"
oServer.Password = "testpassword"
oServer.Protocol = MailServerDAV
oServer.SSLConnection = True

See Also

Using EAGetMail POP3 & IMAP4 ActiveX Object
Registration-free COM with Manifest File
Enable TLS 1.2 on Windows XP/2003/2008/7/2008 R2
Using Gmail IMAP4 OAUTH
Using Gmail/GSuite Service Account + IMAP4 OAUTH
Using Office365 EWS OAUTH
Using Office365 EWS OAUTH in Background Service
Using Hotmail IMAP4 OAUTH
Digital Signature and E-mail Encryption/Decryption
Unique Identifier (UIDL) in POP3 and IMAP4 protocol
Parse Bounced Email (delivery-report)
Work with winmail.dat (TNEF Parser)
EAGetMail ActiveX Object References
EAGetMail POP3 & IMAP4 Component Samples

Online Tutorials

Read Email over SSL/TLS Connection in Delphi - Tutorial
Read Email from Gmail Account in Delphi - Tutorial
Read Email from Yahoo Account in Delphi - Tutorial
Read Email from Hotmail Account in Delphi - Tutorial

Read Email over SSL/TLS Connection in VB6 - Tutorial
Read Email from Gmail Account in VB6 - Tutorial
Read Email from Yahoo Account in VB6 - Tutorial
Read Email from Hotmail Account in VB6 - Tutorial

Read Email over SSL/TLS Connection VC++ - Tutorial
Read Email from Gmail Account in VC++ - Tutorial
Read Email from Yahoo Account in VC++ - Tutorial
Read Email from Hotmail Account in VC++ - Tutorial