SmtpServer Class


Provides properties and methods for constructing a smtp server instance.

System.Object
    EASendMail.SmtpServer

[Visual Basic]
Public Class SmtpServer
[C#]
public class SmtpServer
[C++]
public __gc class SmtpServer
[JScript]
public class SmtpServer

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Public Constructors

SmtpServer Constructor Initializes a new instance of the SmtpServer class.

Public Properties

AuthType Gets or sets the smtp user authentication mechanism.
ConnectType Gets or sets the smtp server connection type.
EHLO Gets or sets using EHLO instead of HELO command.
HeloDomain Gets or sets the domain used in HELO/EHLO command.
MailFrom Gets or sets the e-mail address in MAIL FROM command.
Password Gets or sets the password for user authentication.
Port Gets or sets the port of smtp server.
ProxyProtocol Gets or sets the protocol (socks4/socks5/http) for proxy server.
Server Gets or sets the smtp server address (IP or internet domain name).
SocksProxyServer Gets or sets the socks4/5/http proxy server address (IP or internet domain name).
SocksProxyPort Gets or sets the port of socks4/5/http proxy server.
SocksProxyUser Gets or sets the user for proxy user authentication.
SocksProxyPassword Gets or sets the password for proxy user authentication.
User Gets or sets the user for user authentication.

Example

[Visual Basic, C#, C++] To get the full samples of EASendMail, please refer to Samples section.

[Visual Basic]
Imports EASendMail
Sub SendMail()
    Dim oMail As SmtpMail = New SmtpMail("TryIt")
    Dim oSmtp As SmtpClient = New SmtpClient

    Try
        Dim oServer As SmtpServer = New SmtpServer("smtp.adminsystem.com")
        
        'set user authentication
        'oServer.UserName = "myuser@adminsystem.com"
        'oServer.Password = "mypassword"
        
        'specifies the authentication mechanism.
        'oSmtp.AuthType = SmtpAuthType.AuthAuto
        
        'set SSL connection
        'oServer.ConnectType = SmtpConnectType.ConnectSSLAuto
        
        'set smtp server port
        'oServer.Port = 465
        
        'set helo domain
        'oServer.HeloDomain = "mymachine.com"
        
        'set delivery-report address
        'oServer.MailFrom = "report@adminsystem.com"
        
        
        oMail.From = New MailAddress("from@adminsystem.com")
        oMail.To.Add(New MailAddress("to@adminsystem.com"))
        
        oMail.Subject = "test subject"
        oMail.TextBody = "test body"
                       
        oSmtp.SendMail( oServer, oMail )
        Console.WriteLine( "message was sent" )
        
    Catch exp As SmtpTerminatedException
        Console.WriteLine(exp.Message)
    Catch exp As SmtpServerException
        Console.WriteLine("Exception: Server Respond: {0}", exp.ErrorMessage)
    Catch exp As System.Net.Sockets.SocketException
        Console.WriteLine("Exception: Networking Error: {0} {1}", exp.ErrorCode, exp.Message)
    Catch exp As System.ComponentModel.Win32Exception
        Console.WriteLine("Exception: System Error: {0} {1}", exp.ErrorCode, exp.Message)
    Catch exp As System.Exception
        Console.WriteLine("Exception: Common: {0}", exp.Message)
    End Try

End Sub

[C#]
using System;
using EASendMail;
void SendMail()
{
    SmtpMail oMail = new SmtpMail("TryIt");
    SmtpClient oSmtp = new SmtpClient();

    try
    {
        SmtpServer oServer = new SmtpServer("smtp.adminsystem.com");
        
        //set user authentication
        //oServer.UserName = "myuser@adminsystem.com";
        //oServer.Password = "mypassword";
        
        //specifies the authentication mechanism.
        //oSmtp.AuthType = SmtpAuthType.AuthAuto;
        
        //set SSL connection
        //oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
        
        //set smtp server port
        //oServer.Port = 465;
        
        //set helo domain
        //oServer.HeloDomain = "mymachine.com";
        
        //set delivery-report address
        //oServer.MailFrom = "report@adminsystem.com";
        
                
        oMail.From = new MailAddress("from@adminsystem.com" );
        oMail.To.Add( new MailAddress("to@adminsystem.com" ));
        oMail.Subject = "test subject";
        oMail.TextBody = "test body";
                
        oSmtp.SendMail( oServer, oMail );
        Console.WriteLine( "message was sent" );
    }
    catch( SmtpTerminatedException exp )
    {
        Console.WriteLine( exp.Message );
    }
    catch( SmtpServerException exp )
    {
        Console.WriteLine( "Exception: Server Respond: {0}", exp.ErrorMessage );
    }
    catch( System.Net.Sockets.SocketException exp )
    {
        Console.WriteLine( "Exception: Networking Error: {0} {1}", exp.ErrorCode, exp.Message );
    }
    catch( System.ComponentModel.Win32Exception exp )
    {
        Console.WriteLine( "Exception: System Error: {0} {1}", exp.ErrorCode, exp.Message );            
    }
    catch( System.Exception exp )
    {
        Console.WriteLine( "Exception: Common: {0}", exp.Message );         
    }
}
        
[C++]
using namespace System;
using namespace EASendMail;
void SendMail()
{
    SmtpMail *oMail = new SmtpMail(S"TryIt");
    SmtpClient *oSmtp = new SmtpClient();

    try
    {
        SmtpServer *oServer = new SmtpServer(S"smtp.adminsystem.com");
		
        //set user authentication
        //oServer->UserName = S"myuser@adminsystem.com";
        //oServer->Password = S"mypassword";
        
        //specifies the authentication mechanism.
        //oSmtp->AuthType = SmtpAuthType::AuthAuto;
        
        //set SSL connection
        //oServer->ConnectType = SmtpConnectType::ConnectSSLAuto;
        
        //set smtp server port
        //oServer->Port = 465;
        
        //set helo domain
        //oServer->HeloDomain = S"mymachine.com";
        
        //set delivery-report address
        //oServer->MailFrom = S"report@adminsystem.com";
                    
        oMail->From = new MailAddress(S"from@adminsystem.com" );
        oMail->To->Add( new MailAddress(S"to@adminsystem.com" ));
        oMail->Subject = "test subject";
        oMail->TextBody = "test body";
        
        oSmtp->SendMail( oServer, oMail );
        Console::WriteLine( S"message was sent" );
    }
    catch( EASendMail::SmtpTerminatedException *exp )
    {
        Console::WriteLine( exp->Message );
    }
    catch( EASendMail::SmtpServerException *exp )
    {
        Console::WriteLine( S"Exception: Server Respond: {0}", exp->ErrorMessage );
    }
    catch( System::Net::Sockets::SocketException *exp )
    {
        Console::WriteLine( S"Exception: Networking Error: {0} {1}", exp->ErrorCode.ToString(S"d"), exp->Message );
    }
    catch( System::ComponentModel::Win32Exception *exp )
    {
        Console::WriteLine( S"Exception: System Error: {0} {1}", exp->ErrorCode.ToString(S"d"), exp->Message );           
    }
    catch( System::Exception *exp )
    {
        Console::WriteLine( S"Exception: Common: {0}", exp->Message );           
    }
}