How to Troubleshoot an SMTP Connection Using Command Line in CentOS 8

How to Troubleshoot an SMTP Connection Using Command Line in CentOS 8

What Do I Need?

  • A Dedicated or VPS Linux Server
  • CentOS
  • Putty

What is SMTP?

SMTP is a simple mail transfer protocol that’s a communication protocol for email transmission. It’s an internet standard that was defined in 1982 by RFC 821. User-level email clients use SMTP only for sending messages to a mail server for relaying and most commonly submitting outgoing emails to the mail server on port 587 or 465 as per RFC 8314.

  1. Server Setup
  1. A good tool to use is telnet for getting this done and getting it done right. If no hostname is included with the command it’ll revert to a command prompt.
telnet

How to Troubleshoot an SMTP Connection Using Command Line in CentOS 8

  1. If you find that telnet is missing from your life then you’re going to need to get it installed and stat:
sudo apt-get install telnet

  1. You’ll also need ncat or nc. It’s a general-purpose command-line interface (CLI) tool used for port scanning, security, and monitoring. If ncat or nc isn’t installed, use the following command:
sudo apt-get install openssl

  1. Checking SMTP Connection using Telnet
  1. Telnet to the host that you want to check the connection of. SMTP servers usually communicate over SMTP ports 25, 2525, and 587. The Telnet SMTP test is one of the best ways to figure out your SMTP connection state:
telnet smtp.example.com 25 [2525 ¦ 587]

How to Troubleshoot an SMTP Connection Using Command Line in CentOS 8

  1. Checking the SMTP Connection from Command Line Using Ncat or Nc
  1. Because ncat and nc have various functionalities, we’ll just check the connection using the following command:
nc -v -u smtp.example.com 587

  1. If the connection is successful you’d hope to see something like this:

How to Troubleshoot an SMTP Connection Using Command Line in CentOS 8

  1. Should you have a problem connecting to the host, you’ll see something like this:

How to Troubleshoot an SMTP Connection Using Command Line in CentOS 8

  1. All of the above steps are used to check the SMTP connection from the command line to a particular port of the host.
  1. Checking SMTP Connection over TLS using OpenSSL
  1. In order to set up a tls encrypted connection to an SMTP server, you’ll need the OpenSSL command:
openssl s_client -connect smtp.example.com:587 -starttls smtp

  1. You’ll see a lot of verbose data. If a connection is successfully established you’ll notice a 250 DSN end message:

How to Troubleshoot an SMTP Connection Using Command Line in CentOS 8

  1. Consequently, once you’ve got 250 DSN you can now start your SMTP transaction using the following command:
EHLO “I am here”

How to Troubleshoot an SMTP Connection Using Command Line in CentOS 8

Conclusion

There are a lot of things you can do next but personally, I’d recommend getting used to some of the free tools available for troubleshooting your email server. Using an SMTP check server will normally include several stages:

  • checking your server DNS blacklist status
  • verifying MX records
  • relaying configurations
  • ptr records
  • Verifying the email address

You can use a lot of different free online-based applications for this stuff.

MXToolbox:

It includes simple tests for:

  • SMTP Reverse DNS Mismatch
  • SMTP Valid Hostname
  • SMTP Banner Check
  • SMTP TLS
  • SMTP Connection Time
  • SMTP Open Relay
  • SMTP Transaction Time

However, you’ll find you’re not allowed to define ports or passwords and secure connections aren’t possible.

SMTPer:

SMTPer is perhaps one of the most convenient solutions that allows the definition of a port and provides users with a secure connection and authorization.

test-smtp.com:

Test SMTP simply sends requests to the SMTP server to perform relaying tests. This service doesn’t have any sufficient toolkit for proper SMTP examination, however.

testsmtp.tcsoftware.net:

Check SMTP works for certain parts of a process but know it isn’t enough for a proper examination. It doesn’t provide a secure connection. The following tests can be run:

  • Check your server DNS Black List status
  • Verify MX Records
  • Relay Configuration
  • PTR Record (Reverse Lookup)
  • Verify Email Address
  • Check the recommendations for the best VPS and get a suitable one.

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
2 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How To Set up a VSFTPD Server on an Ubuntu 16.04 VPS or Dedicated Server

Brief Description FTP data is usually insecure since information (usernames, pa
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to use phpMyAdmin to develop a website (without MySQL experience)

Brief description A web developer who is not well versed into coding websites f
2 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Install MySQL on a Windows Web Server Running Apache

This tutorial will show you how to install the MySQL database on a Windows serve
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top