int TestSMTPConnection (string server)
OK if successful;
containing the SMTP server name.
Call this function to test a SMTP mail server's ability to accept
incoming sessions, as well as its level of responsiveness:
- The function opens a connection to the specified SMTP mail
server and waits for the server to respond with a standard "Service
Ready" (code 220) opening message.
- Upon receipt of the opening message, the function safely
disconnects from the server by sending a QUIT command to terminate
the SMTP connection.
- If the mail server fails to respond or responds with an error
code indicating that the Service is not available, the function
considers the test to have failed.
Use TestSMTPConnection to test that:
- A mail client can open a connection with a SMTP mail
- The server adheres to the SMTP protocol by responding with the
- The server responds within a required number of seconds.
Plug-in module: nd_tcpplg.npl
The following example demonstrates the use of
int nStart = GetTickCount()
int nStatus = TestSMTPConnection("mail.netmechanica.com")
if (nStatus == FAIL)
Println("Failed to open SMTP connection")
Println("SMTP server response time: ", GetTickCount() - nStart, "ms")