How to test an SMTP server: telnet, OpenSSL, swaks and a relay check
TL;DR: To test an SMTP server, first check that the port is reachable, then talk to it. Use openssl s_client -starttls smtp -connect host:587 for STARTTLS or -connect host:465 for implicit TLS, or send a full test message with swaks. Reply codes tell you what happened: 220 is ready, 250 is ok, 235 is authenticated, and 5xx is failure. Test relaying only on servers you own, and make sure unauthenticated relaying to outside addresses is refused.
The ports
| Port | Use |
|---|---|
| 25 | Server-to-server mail, often blocked for clients |
| 587 | Submission with STARTTLS and login |
| 465 | Submission with implicit TLS |
First test the connection. See how to check an open port.
Step 1: connect with OpenSSL
openssl s_client -starttls smtp -connect mail.example.com:587
openssl s_client -connect mail.example.com:465
A certificate chain and a 220 greeting show that TLS works. Check that the certificate name matches the host.
Step 2: a manual SMTP session
After connecting you can type commands:
EHLO test.example
AUTH LOGIN
(base64 username)
(base64 password)
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
DATA
Subject: SMTP test
Test message.
.
QUIT
Encode credentials with printf 'user' | base64. Do not paste real passwords into shared logs.
Step 3: swaks, the easy way
swaks sends a full test message in one command:
swaks --to [email protected] --from [email protected] \
--server mail.example.com --port 587 --tls --auth LOGIN \
--auth-user [email protected]
It prompts for the password and prints the full conversation.
Step 4: check relay protection
A server that accepts mail from anyone to anyone is an open relay and will be abused and blacklisted. Connect without logging in and try RCPT TO:<[email protected]>. A good server refuses with a 550 or 554 message. Test only your own servers.
Reading the replies
220service ready250action completed235authentication successful535authentication failed550mailbox unavailable or relay denied554transaction failed
If mail from WordPress is the problem, see WordPress not sending emails. After delivery works, run an email spam test and check SPF, DKIM and DMARC.
FAQs
How do I test an SMTP server?
Connect with OpenSSL or swaks and watch the reply codes.
Which port should I test?
587 or 465 for client submission, 25 for server-to-server.
Why is port 25 blocked?
Many providers block it to limit spam from infected machines.
What does 535 mean?
Authentication failed. Check the username and password.
What is an open relay?
A server that forwards mail from anyone to anyone, which is dangerous.
Can I use telnet?
For plain connections yes, but most servers need TLS, so use OpenSSL.
Is it safe to test with real passwords?
Use a test account and avoid sharing logs.
How do I test from Windows?
Use Test-NetConnection host -Port 587 for the port, and swaks or an online tester for the session.
Conclusion
Test in layers: the port, then TLS, then authentication, then a full message, and finally relay protection. The reply codes point to the exact layer that fails.
HostCloud helps Indian websites with reliable hosting, domains and support. See the options at https://hostcloud.in.
Sources: