SSL_uninit Method


Unload security library for SMTP SSL/TLS connection.

[Syntax]
Visual C++: HRESULT SSL_uninit( )
Visual Basic: SSL_uninit( )

Remarks

Mail object uses SSL/TLS connection to send email after this method is invoked. To cancel SSL/TLS mode, you can invoke SSL_uninit method.

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:

EASendMail SMTP component supports both ways. The connection can be specified by Mail.SSL_starttls property.

Example

[VB, VBA - Send Email over TLS]    
'Connect server over TLS by STARTTLS command
Dim oSmtp As EASendMailObjLib.Mail
Set oSmtp = new EASendMailObjLib.Mail 

oSmtp.LicenseCode = "TryIt" 

oSmtp.ServerAddr = "mail.adminsystem.com" 

' Set User Authentication
oSmtp.UserName = "test@adminsystem.com"
oSmtp.Password = "test"

' Enable TLS Connection
oSmtp.SSL_init
oSmtp.SSL_starttls = 1
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
 
oSmtp.SSL_uninit
 
[VB, VBA - Send Email over SSL]
'Connect server over SSL by direct SSL
Dim oSmtp As EASendMailObjLib.Mail
Set oSmtp = new EASendMailObjLib.Mail 
oSmtp.LicenseCode = "TryIt" 
 
oSmtp.ServerAddr = "mail.adminsystem.com"

' Set User Authentication
oSmtp.UserName = "test@adminsystem.com"
oSmtp.Password = "test"

' Enable SSL Connection
oSmtp.SSL_init
oSmtp.SSL_starttls = 0
'SMTP server usually uses 465 as the alone SSL port
oSmtp.ServerPort = 465 

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
 
oSmtp.SSL_uninit


[VBScript, ASP - Send Email over TLS]    
'Connect server over TLS by STARTTLS command
Dim oSmtp
Set oSmtp = Server.CreateObject("EASendMailObj.Mail") 

oSmtp.LicenseCode = "TryIt" 

oSmtp.ServerAddr = "mail.adminsystem.com" 

' Set User Authentication
oSmtp.UserName = "test@adminsystem.com"
oSmtp.Password = "test"

' Enable TLS Connection
oSmtp.SSL_init
oSmtp.SSL_starttls = 1
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
 
oSmtp.SSL_uninit
 
[VBScript, ASP - Send Email over SSL]
'Connect server over SSL by direct SSL
Dim oSmtp
Set oSmtp = Server.CreateObject("EASendMailObj.Mail")
oSmtp.LicenseCode = "TryIt" 
 
oSmtp.ServerAddr = "mail.adminsystem.com"
' Set User Authentication
oSmtp.UserName = "test@adminsystem.com"
oSmtp.Password = "test"

' Enable SSL Connection
oSmtp.SSL_init
oSmtp.SSL_starttls = 0
'SMTP server usually uses 465 as the alone SSL port
oSmtp.ServerPort = 465 
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
 
oSmtp.SSL_uninit

[Visual C++ - Send Email over TLS]
#include "stdafx.h"
#include <comdef.h>
#include <iostream>

#include "easendmailobj.tlh"
using namespace EASendMailObjLib;

using namespace std;
 
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" );
  
  // Set user authentication
  oSmtp->UserName = _T("test@adminsystem.com"); 
  oSmtp->Password = _T("test");
  
  //Enable TLS connection
  oSmtp->SSL_init();
  oSmtp->SSL_starttls = 1;  
  
  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 )
    cout << _T("Message delivered!") << endl;
  else
    cout << (const TCHAR*)(oSmtp->GetLastErrDescription()) << endl;
}

[Visual C++ - Send Email over SSL]
#include "stdafx.h"
#include <comdef.h>
#include <iostream>

#include "easendmailobj.tlh"
using namespace EASendMailObjLib;

using namespace std;
 
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" );
  
  // Set user authentication
  oSmtp->UserName = _T("test@adminsystem.com"); 
  oSmtp->Password = _T("test");
  
  //Enable SSL connection
  oSmtp->SSL_init();
  oSmtp->SSL_starttls = 0; 
  oSmtp->ServerPort = 465;
  
  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 )
    cout << _T("Message delivered!") << endl;
  else
    cout << (const TCHAR*)(oSmtp->GetLastErrDescription()) << endl;
}

[Delphi - Send Email over TLS]
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;

var
  Form1: TForm1;

implementation
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  oSmtp : TMail;
begin
  oSmtp := TMail.Create(Application);
  oSmtp.LicenseCode := 'TryIt';

  // 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';

  // Your SMTP server address
  oSmtp.ServerAddr := 'smtp.emailarchitect.net';

  // 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';

  // Enable TLS connection
  oSmtp.SSL_init();
  oSmtp.SSL_starttls := 1;  

  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]
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;

var
  Form1: TForm1;

implementation
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  oSmtp : TMail;
begin
  oSmtp := TMail.Create(Application);
  oSmtp.LicenseCode := 'TryIt';

  // 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';

  // Your SMTP server address
  oSmtp.ServerAddr := 'smtp.emailarchitect.net';

  // 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';

  // Enable SSL connection
  oSmtp.SSL_init();
  oSmtp.SSL_starttls := 0; 
  oSmtp.ServerPort := 465;        

  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

SSL_uninit Method