How to Test SMTP Connectivity and STARTTLS

A successful connection to an SMTP port proves reachability, not that a message can be authenticated, relayed or delivered. Test those layers separately so each result answers a specific question about the connection.

Check the expected host and port

Use the mail service's documented endpoint. In Windows PowerShell:

PowerShell
Test-NetConnection -ComputerName 'smtp.example.com' -Port 587 -InformationLevel Detailed

Replace the example host with the real endpoint. TcpTestSucceeded: True confirms that a TCP connection could be established. A failed test needs DNS, routing, firewall or listener investigation before an application-password change will help.

Port 25 commonly handles server-to-server SMTP, 587 commonly handles message submission with STARTTLS, and 465 uses implicit TLS. The provider's actual configuration is authoritative.

Inspect STARTTLS without sending mail

With OpenSSL installed and a suitable trusted CA store configured:

Plain text
openssl s_client -connect smtp.example.com:587 -starttls smtp -servername smtp.example.com -verify_hostname smtp.example.com -verify_return_error -crlf

The command performs the SMTP STARTTLS negotiation before the TLS handshake. Check certificate validation and the hostname result. After the encrypted session is established, send:

Plain text
EHLO test.example
QUIT

Expect an SMTP capability response and a clean quit response from a cooperative server. This exchange does not submit a message. If OpenSSL cannot locate trusted CA certificates on the test machine, configure the correct trust material rather than disabling verification.

Interpret the boundary correctly

A 220 greeting confirms an SMTP service answered. Its product banner is not a reliable IIS-version test. A validated TLS session proves a different layer. Neither proves the account may authenticate or relay to a destination.

Do not paste credentials into a plaintext Telnet session. Test actual submission using the provider's supported authentication mechanism and a controlled test message only when delivery testing is intended. For implicit TLS on port 465, omit -starttls smtp. Do not mix the two connection modes.

References

Test-NetConnection (NetTCPIP)
Use this topic to help manage Windows and Windows Server technologies with Windows PowerShell.
https://learn.microsoft.com/en-us/powershell/module/nettcpip/test-netconnection
Test-NetConnection
openssl-s_client - OpenSSL Documentation
https://docs.openssl.org/3.5/man1/openssl-s_client/
OpenSSL s_client

Author: Herman Schoenfeld