This property specifies current connection type to SMTP server.
Data Type: Long
Value | Meaning |
0 (default value) | Specifies that the SMTP server uses normal TCP/IP connection. |
1 | Specifies that the SMTP client selects the STARTTLS/Direct SSL automatically. |
2 | Specifies that the SMTP server deploys SSL connection by STARTTLS command. |
3 | Specifies that the SMTP server deploys SSL connection directly. |
4 | If SMTP server supports TLS, then TLS connection is used; otherwise, normal TCP connection is used. |
SMTP SSL/TLS Connection
SSL connection encrypts data between the SMTP component and SMTP server to protects user, password and email content in TCP/IP level. Now this technology is commonly used and many SMTP servers are deployed with SSL such as gmail. There are two ways to deploy SSL on SMTP server:
TLS 1.2 Encryption
TLS is the successor of SSL, EASendMail supports SSL 3.0/TLS1.0 - 1.2 very well. In EASendMail, ConnectSTARTTLS doesn't mean TLS encryption, it means STARTTLS command in SMTP 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 ConnectSSLAuto, ConnectSTARTTLS, ConnectDirectSSL and ConnectTryTLS.
To enable TLS 1.2 on Windows 2008/2008 R2/7, please install this update:
https://www.microsoft.com/security/blog/2017/07/20/tls-1-2-support-added-to-windows-server-2008/
Example
[VB, VBA - Send Email over TLS on 25/587 project] Const ConnectNormal = 0 Const ConnectSSLAuto = 1 Const ConnectSTARTTLS = 2 Const ConnectDirectSSL = 3 Const ConnectTryTLS = 4 ' Connect server over TLS by STARTTLS command on 25/587 port Dim oSmtp As EASendMailObjLib.Mail Set oSmtp = new EASendMailObjLib.Mail oSmtp.LicenseCode = "TryIt" oSmtp.ServerAddr = "mail.adminsystem.com" oSmtp.ServerPort = 25 ' Enable SSL/TLS Connection oSmtp.ConnectType = ConnectSSLAuto ' Set User Authentication oSmtp.UserName = "test@adminsystem.com" oSmtp.Password = "test" oSmtp.Subject = "test for ssl" oSmtp.BodyText = "test body" oSmtp.FromAddr = "test@adminsystem.com" oSmtp.AddRecipient "Support Team", "Support@adminsystem.com", 0 If oSmtp.SendMail() = 0 Then MsgBox "Message delivered" Else MsgBox oSmtp.GetLastErrDescription() End If
[VB, VBA - Send Email over SSL on 465 port] Const ConnectNormal = 0 Const ConnectSSLAuto = 1 Const ConnectSTARTTLS = 2 Const ConnectDirectSSL = 3 Const ConnectTryTLS = 4 ' Connect server over SSL by direct SSL on 465 port Dim oSmtp As EASendMailObjLib.Mail Set oSmtp = new EASendMailObjLib.Mail oSmtp.LicenseCode = "TryIt" oSmtp.ServerAddr = "mail.adminsystem.com" ' SMTP server usually uses 465 as the alone SSL port oSmtp.ServerPort = 465 ' Enable SSL/TLS Connection oSmtp.ConnectType = ConnectSSLAuto ' Set User Authentication oSmtp.UserName = "test@adminsystem.com" oSmtp.Password = "test" oSmtp.Subject = "test for ssl" oSmtp.BodyText = "test body" oSmtp.FromAddr = "test@adminsystem.com" oSmtp.AddRecipient "Support Team", "Support@adminsystem.com", 0 If oSmtp.SendMail() = 0 Then MsgBox "Message delivered" Else MsgBox oSmtp.GetLastErrDescription() End If
[VBScript, ASP - Send Email over TLS on 25/587 port] Const ConnectNormal = 0 Const ConnectSSLAuto = 1 Const ConnectSTARTTLS = 2 Const ConnectDirectSSL = 3 Const ConnectTryTLS = 4 ' Connect server over TLS by STARTTLS command on 25 port Dim oSmtp Set oSmtp = Server.CreateObject("EASendMailObj.Mail") oSmtp.LicenseCode = "TryIt" oSmtp.ServerAddr = "mail.adminsystem.com" oSmtp.ServerPort = 25 ' Enable SSL/TLS Connection oSmtp.ConnectType = ConnectSSLAuto ' Set User Authentication oSmtp.UserName = "test@adminsystem.com" oSmtp.Password = "test" oSmtp.Subject = "test for ssl" oSmtp.BodyText = "test body" oSmtp.FromAddr = "test@adminsystem.com" oSmtp.AddRecipient "Support Team", "Support@adminsystem.com", 0 If oSmtp.SendMail() = 0 Then Response.Write "Message delivered" Else Response.Write oSmtp.GetLastErrDescription() End If
[VBScript, ASP - Send Email over SSL on 465 port] Const ConnectNormal = 0 Const ConnectSSLAuto = 1 Const ConnectSTARTTLS = 2 Const ConnectDirectSSL = 3 Const ConnectTryTLS = 4 ' Connect server over SSL by direct SSL on 465 port Dim oSmtp Set oSmtp = Server.CreateObject("EASendMailObj.Mail") oSmtp.LicenseCode = "TryIt" oSmtp.ServerAddr = "mail.adminsystem.com" 'SMTP server usually uses 465 as the alone SSL port oSmtp.ServerPort = 465 ' Enable SSL/TLS Connection oSmtp.ConnectType = ConnectSSLAuto ' Set User Authentication oSmtp.UserName = "test@adminsystem.com" oSmtp.Password = "test" oSmtp.Subject = "test for ssl" oSmtp.BodyText = "test body" oSmtp.FromAddr = "test@adminsystem.com" oSmtp.AddRecipient "Support Team", "Support@adminsystem.com", 0 If oSmtp.SendMail() = 0 Then Response.Write "Message delivered" Else Response.Write oSmtp.GetLastErrDescription() End If
[Visual C++ - Send Email over TLS on 25/587 port] #include "stdafx.h" #include <tchar.h> #include <Windows.h> #include "EASendMailObj.tlh" using namespace EASendMailObjLib; const int ConnectNormal = 0; const int ConnectSSLAuto = 1; const int ConnectSTARTTLS = 2; const int ConnectDirectSSL = 3; const int ConnectTryTLS = 4; void SendEmail() { ::CoInitialize(NULL); IMailPtr oSmtp = NULL; oSmtp.CreateInstance(__uuidof(EASendMailObjLib::Mail)); // The license code for EASendMail ActiveX Object, // for evaluation usage, please use "TryIt" as the license code. oSmtp->LicenseCode = _T("TryIt"); oSmtp->ServerAddr = _T("mail.adminsystem.com"); oSmtp->ServerPort = 25; // Enable SSL/TLS connection oSmtp->ConnectType = ConnectSSLAuto; // Set user authentication oSmtp->UserName = _T("test@adminsystem.com"); oSmtp->Password = _T("test"); oSmtp->FromAddr = _T("test@adminsystem.com"); oSmtp->AddRecipient(_T("Support Team"), _T("support@adminsystem.com"), 0); oSmtp->Subject = _T("Test"); oSmtp->BodyText = _T("Hello, this is a test email from VC++ ...."); if (oSmtp->SendMail() == 0) _tprintf(_T("Message delivered!")); else _tprintf((const TCHAR*)oSmtp->GetLastErrDescription()); }
[Visual C++ - Send Email over SSL on 465 port] #include "stdafx.h" #include <tchar.h> #include <Windows.h> #include "EASendMailObj.tlh" using namespace EASendMailObjLib; const int ConnectNormal = 0; const int ConnectSSLAuto = 1; const int ConnectSTARTTLS = 2; const int ConnectDirectSSL = 3; const int ConnectTryTLS = 4; void SendEmail() { ::CoInitialize(NULL); IMailPtr oSmtp = NULL; oSmtp.CreateInstance(__uuidof(EASendMailObjLib::Mail)); // The license code for EASendMail ActiveX Object, // for evaluation usage, please use "TryIt" as the license code. oSmtp->LicenseCode = _T("TryIt"); oSmtp->ServerAddr = _T("mail.adminsystem.com"); oSmtp->ServerPort = 465; // Enable SSL/TLS connection oSmtp->ConnectType = ConnectSSLAuto; // Set user authentication oSmtp->UserName = _T("test@adminsystem.com"); oSmtp->Password = _T("test"); oSmtp->FromAddr = _T("test@adminsystem.com"); oSmtp->AddRecipient(_T("Support Team"), _T("support@adminsystem.com"), 0); oSmtp->Subject = _T("Test"); oSmtp->BodyText = _T("Hello, this is a test email from VC++ ...."); if (oSmtp->SendMail() == 0) _tprintf(_T("Message delivered!")); else _tprintf((const TCHAR*)oSmtp->GetLastErrDescription()); }
[Delphi - Send Email over TLS on 25/587 port] unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, EASendMailObjLib_TLB; // add EASendMail unit type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; const ConnectNormal = 0; ConnectSSLAuto = 1; ConnectSTARTTLS = 2; ConnectDirectSSL = 3; ConnectTryTLS = 4; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var oSmtp : TMail; begin oSmtp := TMail.Create(Application); oSmtp.LicenseCode := 'TryIt'; // Your SMTP server address oSmtp.ServerAddr := 'smtp.emailarchitect.net'; oSmtp.ServerPort := 25; // Enable SSL/TLS connection oSmtp.ConnectType := ConnectSSLAuto; // User and password for ESMTP authentication, // If your server doesn't require user authentication, please remove the following codes oSmtp.UserName := 'test@emailarchitect.net'; oSmtp.Password := 'testpassword'; // Set your sender email address oSmtp.FromAddr := 'test@emailarchitect.net'; // Add recipient email address oSmtp.AddRecipientEx('support@emailarchitect.net', 0); // Set email subject oSmtp.Subject := 'simple email from Delphi project'; // Set email body oSmtp.BodyText := 'this is a test email sent from Delphi project, do not reply'; ShowMessage('start to send email ...'); if oSmtp.SendMail() = 0 then ShowMessage('email was sent successfully!') else ShowMessage('failed to send email with the following error: ' + oSmtp.GetLastErrDescription()); end; end.
[Delphi - Send Email over SSL on 465 port] unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, EASendMailObjLib_TLB; // add EASendMail unit type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; const ConnectNormal = 0; ConnectSSLAuto = 1; ConnectSTARTTLS = 2; ConnectDirectSSL = 3; ConnectTryTLS = 4; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var oSmtp : TMail; begin oSmtp := TMail.Create(Application); oSmtp.LicenseCode := 'TryIt'; // Your SMTP server address oSmtp.ServerAddr := 'smtp.emailarchitect.net'; oSmtp.ServerPort := 465; // Enable SSL/TLS connection oSmtp.ConnectType := ConnectSSLAuto; // User and password for ESMTP authentication, // If your server doesn't require user authentication, please remove the following codes oSmtp.UserName := 'test@emailarchitect.net'; oSmtp.Password := 'testpassword'; // Set your sender email address oSmtp.FromAddr := 'test@emailarchitect.net'; // Add recipient email address oSmtp.AddRecipientEx('support@emailarchitect.net', 0); // Set email subject oSmtp.Subject := 'simple email from Delphi project'; // Set email body oSmtp.BodyText := 'this is a test email sent from Delphi project, do not reply'; ShowMessage('start to send email ...'); if oSmtp.SendMail() = 0 then ShowMessage('email was sent successfully!') else ShowMessage('failed to send email with the following error: ' + oSmtp.GetLastErrDescription()); end; end.
Online Examples
Send Email over SSL/TLS - VB6
Send Email over SSL/TLS - VC++
Send Email over SSL/TLS - Delphi
Online Tutorial
Send Email over SSL/TLS in VB6
Send Email using Gmail in VB6
Send Email using Yahoo in VB6
Send Email using Hotmail/Live in VB6
Send Email over SSL/TLS in VC++
Send Email using Gmail in VC++
Send Email using Yahoo in VC++
Send Email using Hotmail/Live in VC++
Send Email over SSL/TLS in Delphi
Send Email using Gmail in Delphi
Send Email using Yahoo in Delphi
Send Email using Hotmail/Live in Delphi
See Also