SmtpConnectType Enumeration


Specifies the connection type to smtp server.

[Visual Basic]
Public Enum SmtpConnectType
[C#]
public enum SmtpConnectType
[C++]
__value public enum SmtpConnectType
[JScript]
public enum SmtpConnectType

Members

Members name Description
ConnectNormal Specifies that the smtp server uses normal TCP/IP connection.
ConnectSSLAuto Specifies that the smtp client selects the STARTTLS/Direct SSL automatically.
ConnectSTARTTLS Specifies that the smtp server deploys SSL connection by STARTTLS command.
ConnectDirectSSL Specifies that the smtp server deploys SSL connection directly.
ConnectTryTLS If smtp server supports TLS, then TLS connection is used; otherwise, normal TCP connection is used.

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 or ConnectDirectSSL.

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

[Visual Basic, C#, C++] The following example demonstrates how to send email with SmtpClient class. To get the full samples of EASendMail, please refer to Samples section.

[VB - Send Email using SMTP Server over SSL/TLS connection]

Imports EASendMail

Sub SendMail()

    Try
        Dim oServer As SmtpServer = New SmtpServer("smtp.adminsystem.com")
        ' set user authentication
        oServer.User = "myuser@adminsystem.com"
        oServer.Password = "mypassword"
        
        ' specifies the authentication mechanism, AuthAuto is default value
        ' oSmtp.AuthType = SmtpAuthType.AuthAuto
        
        ' set SSL/TLS connection
        oServer.ConnectType = SmtpConnectType.ConnectSSLAuto
        
        ' set SMTP server port to 587, default value is 25
        ' oServer.Port = 587

        ' set SMTP server port to 465, 
        ' if 465 port is used, ConnectType should use ConnectSSLAuto or ConnectDirectSSL.
        ' oServer.Port = 465
        
        ' set helo domain, default value is current machine name
        ' oServer.HeloDomain = "mymachine.com"
        
        Dim oMail As SmtpMail = New SmtpMail("TryIt")
        oMail.From = New MailAddress("from@adminsystem.com")
        oMail.To.Add(New MailAddress("to@adminsystem.com"))
        
        oMail.Subject = "test email sent from VB"
        oMail.TextBody = "test body"
                        
        Dim oSmtp As SmtpClient = New SmtpClient()
        oSmtp.SendMail(oServer, oMail)
        Console.WriteLine("This email has been submitted to server successfully!")

    Catch exp As Exception
        Console.WriteLine("Exception: {0}", exp.Message)
    End Try

End Sub


[C# - Send Email using SMTP Server over SSL/TLS connection] using System; using EASendMail; void SendMail() { try { // SMTP server address SmtpServer oServer = new SmtpServer("smtp.adminsystem.com"); // SMTP user authentication oServer.User = "myusername"; oServer.Password = "mypassword"; // specifies the authentication mechanism, AuthAuto is default value // oSmtp.AuthType = SmtpAuthType.AuthAuto; // set SSL/TLS connection oServer.ConnectType = SmtpConnectType.ConnectSSLAuto; // set SMTP server port to 587, default value is 25 // oServer.Port = 587; // set SMTP server port to 465, // if 465 port is used, ConnectType should use ConnectSSLAuto or ConnectDirectSSL. // oServer.Port = 465; // set helo domain, default value is current machine name // oServer.HeloDomain = "mymachine.com"; SmtpMail oMail = new SmtpMail("TryIt"); oMail.From = new MailAddress("from@adminsystem.com"); oMail.To.Add(new MailAddress("to@adminsystem.com")); oMail.Subject = "test email sent from C#"; oMail.TextBody = "test body"; SmtpClient oSmtp = new SmtpClient(); oSmtp.SendMail(oServer, oMail); Console.WriteLine("This email has been submitted to server successfully!"); } catch(Exception exp) { Console.WriteLine("Exception: {0}", exp.Message); } }
[C++/CLI - Send Email using SMTP Server over SSL/TLS connection] using namespace System; using namespace EASendMail; void SendMail() { try { // SMTP server address SmtpServer ^oServer = gcnew SmtpServer("smtp.adminsystem.com"); // SMTP user authentication oServer->User = "myusername"; oServer->Password = "mypassword"; // specifies the authentication mechanism, AuthAuto is default value // oSmtp.AuthType = SmtpAuthType::AuthAuto; // set SSL/TLS connection oServer->ConnectType = SmtpConnectType::ConnectSSLAuto; // set SMTP server port to 587, default value is 25 // oServer->Port = 587; // set SMTP server port to 465, // if 465 port is used, ConnectType should use ConnectSSLAuto or ConnectDirectSSL. // oServer->Port = 465; // set helo domain, default value is current machine name // oServer->HeloDomain = "mymachine.com"; SmtpMail ^oMail = gcnew SmtpMail("TryIt"); oMail->From = gcnew MailAddress("from@adminsystem.com"); oMail->To->Add(gcnew MailAddress("to@adminsystem.com")); oMail->Subject = "test email sent from C++/CLI"; oMail->TextBody = "test body"; SmtpClient ^oSmtp = gcnew SmtpClient(); oSmtp->SendMail(oServer, oMail); Console::WriteLine("This email has been submitted to server successfully!"); } catch(Exception ^exp) { Console::WriteLine("Exception: {0}", exp->Message); } }

See Also

User Authentication and SSL Connection
From, ReplyTo, Sender and Return-Path
Process Bounced Email (Non-Delivery Report) and Email Tracking

Online Tutorial

Send Email over SSL/TLS in C#
Send Email using Gmail in C#
Send Email using Yahoo in C#
Send Email using Hotmail/Live in C#

Send Email over SSL/TLS in VB
Send Email using Gmail in VB
Send Email using Yahoo in VB
Send Email using Hotmail/Live in VB

Send Email over SSL/TLS in C++/CLI
Send Email using Gmail in C++/CLI
Send Email using Yahoo in C++/CLI
Send Email using Hotmail/Live in C++/CLI