1. About connection with the server
Connections to the SMTP server generally use two ways:
The first:
When the server address is a string type, such as "SMTP.TOM.com", "211.128.11.25", we can establish a connection with TCPClient classes.
TcpClient = New TcpClient (SMTPSERVER, SMTPPORT);
Participation Space:
System.net.sockets.tcpclient
In order for TCPClient to connect and exchange data, the TCPListener or Socket created using TCP ProtocolType must listen for incoming connection requests. You can use one of the following two methods to connect to the listener:
Create a TCPCLIENT and call one of three available Connect methods. Create TCPClient using the host name and port number of the remote host. This constructor will automatically try a connection.
Second: When the server address is in the form of an IP address, it will use the IpendPoint class. IPEndPoint smtpServerIPEndPoint = new IPEndPoint (smtpServerIPAddress, smtpPort); we can string type of server addresses into an IP address in the form:. IPAddress hostIPAddress = (Dns.Resolve (hostString)) AddressList [0]; under the namespace: System.Net. The EndPoint IpendPoint class contains the host and port information required to connect to the service on the host. By combining the host IP address and port number, the IpendPoint class is formed to the service connection point.