SSL Object

The SSL object enables the SMTP, POP3 and IMAP4 mailer objects to communicate to email servers over secure SSL and TLS connections. The TLS, as the most secure protocol in comparison to SSL, is used by default.

The SSL object is never used on its own. You always access it via SSL property of SMTP, POP3 and IMAP4 mailer objects. To enable secure connection mode, you must set Enabled=True and also set UseStartTLS=True of SSL object (for STARTTLS connections) or PortNumber of mailer object (for dedicated SSL port connections). See details below.

Syntax

SSL.property|method

 

Properties
AutosetPortAndSSL Enables automatic setting of SSL mode accordingly the server name and port.
ClientCert Contains details on the currently selected client certificate.
Enabled Enables secure connections.
Protocol Specifies the security protocol to be used (e.g. TLS 1.0, TLS 1.2).
ServerCert Contains details on the mail server certificate.
SSLError Returns completion status of the last security-related operation.
SSLSpecificError Contains security-related error code returned by Windows API functions.
UseStartTLS Specifies whether secure connections must use regular port instead of dedicated port.
VerifyServerCert Specifies whether to abort the connection if the mail server does not have a trusted certificate.
Methods
SelectClientCert Selects client certificate from the specified registry or file store.
SelectServerCertStore Selects the registry or file store against which the mail server certificate will be validated.

 

Remarks

Secure communications take advantage of client and server certificates to authenticate clients and servers. The SSL object supports both types of the certificates including anonymous (i.e. missing) client certificates. You can verify server certificates, search and select client certificates, display information regarding server and client certificates.

Note: The SSL object supports secure connections over dedicated port and over regular port. Some mail servers support both types of the connections, others - only one of these types or even do not support secure connections at all. Consult your mail server administration or documentation to determine which type of the secure connection is supported by your server.

Secure connection over dedicated port uses a port specially reserved for secure connections. The following ports are usually used:
Protocol Dedicated port number
SMTP 465
POP3 995
IMAP4 993
To change port number, set PortNumber property of the SMTP, POP3 or IMAP4 object. By default, MailBee can automatically set the appropriate SSL mode based on the port number you specified (see AutosetPortAndSSL topic for details). However, it's always recommended not to rely on the automatic setting and set everything manually (this means setting Enabled and UseStartTLS properties).

Secure connection over regular port uses the same port as simple insecure connection does. The connection starts in non-secure mode and then switches into secure mode using STARTTLS command (or STLS command for the POP3 protocol). Regular ports are:
Protocol Regular port number
SMTP 25
POP3 110
IMAP4 143
Because regular port numbers are set by default, you do not need to change PortNumber property value. To enable STARTTLS connections, set UseStartTLS property of the SSL object to True.

Note: The default SSL protocol in Windows is TLS 1.0. This version of TLS protocol is now considered weak so it's recommended to specify TLS 1.2 (it, however, must be supported by your mail server). See Protocol property for details).

 

Example

The following example sends an e-mail through secure channel. The secure connection is created through default port for regular SMTP connections. To enter secure mode, STARTTLS command is used (UseStartTLS is set to True).
Dim objSMTP

' Using Visual Basic to create object
Set objSMTP = CreateObject("MailBee.SMTP")

' Using ASP to create object
' Set objSMTP = Server.CreateObject("MailBee.SMTP")
'
' In ASP, use Response.Write instead of MsgBox

' Unlock SMTP mailer
objSMTP.LicenseKey = "SMTP license key"

' Enable secure connection over regular port
objSMTP.SSL.Enabled = True
objSMTP.SSL.UseStartTLS = True

' Set SMTP server name
objSMTP.ServerName = "mail.server.com"

' Set message properties
objSMTP.Message.ToAddr = "bill@yoursite.com"
objSMTP.Message.FromAddr = "joe@mysite.com"
objSMTP.Message.Subject = "Subject"
objSMTP.Message.BodyText = "Body"

' Send message
If objSMTP.Send Then
  ' Succeeded!!
  MsgBox "Sent successfully"
Else
  ' Failed...
  MsgBox "Error #" & objSMTP.ErrCode & _
    ", Last server reply:" & objSMTP.ServerResponse
End If

' Close the connection
objSMTP.Disconnect

 

See Also

SMTP.SSL Property, POP3.SSL Property, IMAP4.SSL Property

 


Send feedback to AfterLogic
Copyright © 2002-2022, AfterLogic Corporation. All rights reserved.