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 more secure protocol, is used by default.

The SSL object is never used on its own. To enable secure connection mode, you must create an instance of the SSL object, set its properties (at least, LicenseKey property), and then set the mailer object's SSL property value to a reference to the SSL object:

...
Set objSSL = CreateObject("MailBee.SSL")
objSSL.LicenseKey = "SSL license key"
Set objSMTP.SSL = objSSL
...

Note: The SSL object is included in MailBee SMIME/SSL Plugin which is sold separately, and requires its own license key. However, when you get 30-days trial license key for MailBee Objects, this trial key is also valid for SMIME/SSL Plugin and SSL object.

Syntax

SSL.property|method

 

Properties
ClientCert Contains details on the currently selected client certificate.
Licensed Indicates whether valid license key has been assigned to the SSL object.
LicenseKey Sets the license key to be used with the SSL object.
Protocol Specifies the security protocol to be used.
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 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.

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.

 

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, objSSL

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

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

' Unlock SMTP mailer and SSL plugin
objSMTP.LicenseKey = "SMTP license key"
objSSL.LicenseKey = "SSL license key"

' Specify SSL object for the mailer object
Set objSMTP.SSL = objSSL

' Enable secure connection over regular port
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-2009, AfterLogic Corporation. All rights reserved.