Testing Email Server configuration in Linux ( RHEL5/RHEL6)

If you’ve been following along, you’ve likely been so busy setting up the mail servers that you still haven’t had the chance to test them. Verifying the functionality of your mail servers is always a good idea to make sure they are working properly.

Even though you configured a secure Dovecot server in the preceding section, I changed it back to the unsecure version for testing purposes. First, you need to check the Postfix server both locally and remotely to make sure outgoing mail is working.

You can use the mail command to make some quick tests to the SMTP protocol.

Step 1. For the local mail test, use the following:

# echo “Hello User01” | mail -s “Local Test” user01

If you don’t see any error messages, your message went through.

Step 2. For the remote mail test, use the following:

# echo “Hello again User01” | mail -s “Remote Test”

After your messages are sent, you can use the mailq command with the -v option to view the queue of messages that have been sent or are waiting to be sent. This command produces a lot of output, so you may
need to scroll around to find what you’re looking for.

Step 3. A third way to test that the mail server is accepting connections properly is to telnet into the Postfix server on port 25:

# telnet 25
Connected to localhost.localdomain (
Escape character is ‘^]’.
220 rhel01.example.com ESMTP Postfix
221 2.0.0 Bye
Connection closed by foreign host.

NOTE: On RHEL6, the Telnet package is not installed by default. If you plan to use the Telnet client to verify functionality, you need to install it before use.

You can see that everything for the Postfix server seems to be operating normally.

Now let’s move on to the Dovecot server. You can use the mutt command to read mail from the Dovecot server that you just sent to user01.

Syntax: mutt -f <imap | imaps | pop | pops>://<user><port>

Check your mail:

# mutt -f imap://user01143

As with Postfix, you can also use Telnet to verify the connection is working properly:

# telnet 110
Connected to rhel01.example.com (
Escape character is ‘^]’.
+OK Dovecot ready.
user user01
pass password
+OK Logged in.
+OK 0 messages:
+OK Logging out.
Connection closed by foreign host.

Again, you can see that everything connected fine. Both the mail services are running properly.

If you run into a situation in which the mail server isn’t working properly, you can also check the queue to make sure mail is being sent out properly.

Display current mail in the queue:

# mailq
-Queue ID- –Size– —-Arrival Time—- -Sender/Recipient——-
099FCA110E 441 Thu Feb 3 06:40:21 root@example.com
(connect to example.com[]:25: Connection timed out)

For some reason, this message seems to be stuck in the queue (I disabled the network interface to generate an error). You can just delete it from the queue and send it again later.

Syntax: postsuper [options]

-d queue_id Deletes one message with the named queue ID (you can also specify
ALL as the queue_id to erase all messages in the queue)
-h queue_id Puts the specific message defined by queue_id “on hold”
-H queue_id Releases the message that was put “on hold”
-r queue_id Requeues a message
-s Performs a structure check of directories
-v Provides verbose logging

Delete the stuck message on the queue:

# postsuper -d 099FCA110E
postsuper: 099FCA110E: removed
postsuper: Deleted: 1 message

Verify that the queue is now clean:

# mailq
Mail queue is empty

November 16, 2015

0 responses on "Testing Email Server configuration in Linux ( RHEL5/RHEL6)"

Leave a Message

Why Unixadminschool.com?

These days, working as UNIX and Linux system administrator is just more than knowing about any single operating system or technology. Our training content is carefully designed to explain real world scenarios in easy and systematic manner, so that you don’t need to spend so much time to understand these concepts from different sources – like expert blogs, books and forums.
Visit Us On TwitterVisit Us On FacebookVisit Us On Google PlusVisit Us On YoutubeVisit Us On Linkedin