How to Test Posfix Mail Service using Telnet

PosfixIn order to test the mail services working properly, testing needs to be performed. Instead of using GUI mail client or webmail to test the sending and receiving email,you also can use telnet. Telnet is the most basic mail client. It does the same thing as advanced mail client such as Microsoft Outlook and Mozilla Thunderbird. Telnet will verify and check the server responses to mail requests that was typed.

Perform Testing for Posfix Mail Service using Telnet on linux shell :

[root@mail ~]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.zimbra.local ESMTP Postfix
Helo mail.zimbra.local
250 mail.zimbra.local
MAIL FROM:<admin@zimbra.local>
250 2.1.0 Ok
RCPT TO:<user@zimbra.local>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: My Test Email
This is the body of the Email
.
250 2.0.0 Ok: queued as 194869C1AB
quit
221 2.0.0 Bye
Connection closed by foreign host.

Perform Testing for Posfix Mail Service using Telnet on Windows Command Prompt :

C:\>telnet mail.zimbra.local 25

220 mail.zimbra.local ESMTP Postfix
ehlo mail.zimbra.local
250-mail.zimbra.local
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
MAIL FROM:<admin@zimbra.local>
250 2.1.0 Ok
RCPT TO:<user@zimbra.local>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: My Test Email
This is the body of the EMAIL Message!
.
250 2.0.0 Ok: queued as 538BB9C1AD

Steps to Perform Testing the Postfix Mail Service

1. Establish a TCP connection to port 25 which is postfix port :

[root@mail ~]# telnet localhost 25

You should receive a 220 response:

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.zimbra.local ESMTP Postfix

Postfix is listening and we can communicate with SMTP now.

See also  How to Install the Dependencies for GForge Community Edition and GForge Advanced Server

2. Next,greet the postfix server. The function is considered same with postman or transport :

Helo mail.zimbra.local

The postfix mail server should respond as below :

250 mail.zimbra.local

3. Inform the postfix server know who the sender is:

MAIL FROM:<admin@zimbra.local>

You will get ‘250’ output if the postfix accepts the sender address :

250 2.1.0 Ok

4. Specify the recipient of the email :

RCPT TO:<user@zimbra.local>

If Postfix accepts the recipient address will returned 250 response :

250 2.1.5 Ok

5. Send the actual Email with subject and body of the email :

DATA

Postfix agrees and feedback us to start actual email and returned this output :

354 End data with <CR><LF>.<CR><LF>

6. Start compose the mail, type the word ‘Subject:’ for email subject then enter. Type email body end our input with a dot.

Subject: My Test Email
This is the body of the Email
.

As before, if postfix agress and accepts the email, it will returned 250 response :

250 2.0.0 Ok: queued as 194869C1AB

7. Postfix test fixt telnet finished at the moment, So you can quit :

quit
221 2.0.0 Bye
Connection closed by foreign host.

Trace the mail on Postfix Mail server using message ID :

On Linux shell, message id is 194869C1AB :

[root@mail ~]# cat /var/log/maillog | grep 194869C1AB
Jun  5 01:58:21 mail postfix/smtpd[12285]: 194869C1AB: client=localhost.localdomain[127.0.0.1]
Jun  5 01:59:24 mail postfix/cleanup[17117]: 194869C1AB: message-id=<20120604175821.194869C1AB@mail.zimbra.local>
Jun  5 01:59:24 mail postfix/qmgr[4464]: 194869C1AB: from=<admin@zimbra.local>, size=409, nrcpt=1 (queue active)
Jun  5 01:59:25 mail postfix/cleanup[17117]: 52A7E9C1AD: message-id=<20120604175821.194869C1AB@mail.zimbra.local>
Jun  5 01:59:25 mail postfix/smtp[17317]: 194869C1AB: to=<user@zimbra.local>, relay=127.0.0.1[127.0.0.1]:10024, delay=73, delays=72/0.02/0.1/0.76, dsn=2.0.0, status=sent (250 2.0.0 from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as 52A7E9C1AD)
Jun  5 01:59:25 mail postfix/qmgr[4464]: 194869C1AB: removed

On Windows Command Prompt, the message id is 538BB9C1AD.

[root@mail ~]# cat /var/log/maillog | grep 538BB9C1AD
Jun  5 02:14:08 mail postfix/smtpd[21232]: 538BB9C1AD: client=unknown[192.168.1.52]
Jun  5 02:14:55 mail postfix/cleanup[22300]: 538BB9C1AD: message-id=<20120604181408.538BB9C1AD@mail.zimbra.local>
Jun  5 02:14:55 mail postfix/qmgr[4464]: 538BB9C1AD: from=<admin@zimbra.local>, size=408, nrcpt=1 (queue active)
Jun  5 02:15:05 mail postfix/cleanup[22300]: EDD0E9C1AE: message-id=<20120604181408.538BB9C1AD@mail.zimbra.local>
Jun  5 02:15:05 mail postfix/smtp[22317]: 538BB9C1AD: to=<user@zimbra.local>, relay=127.0.0.1[127.0.0.1]:10024, delay=74, delays=65/0.02/1.6/7.8, dsn=2.0.0, status=sent (250 2.0.0 from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as EDD0E9C1AE)
Jun  5 02:15:05 mail postfix/qmgr[4464]: 538BB9C1AD: removed

How to Reset the Directory Manager Password on RHEL 7 / CentOS 7
How to Reset the Directory Manager Password on RHEL 7 / CentOS 7

It is best practice to remember passwords, but because too many passwords, sometimes we forget. We are not encouraged to write the password on any paper or share the password...

How to Find Big Files Size on Linux RHEL/CentOS
How to Find Big Files Size on Linux RHEL/CentOS

As the linux administrator, sometimes we have to identify which files are most take much space in the linux server resulting in low free space. Low disk space can also...

Why Linux users should worry about malware and what they can do about it
Why Linux users should worry about malware and what they can do about it

Don’t drop your guard just because you’re running Linux. Preventing the spread of malware and/or dealing with the consequences of infection are a fact of life when using computers. If...

How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7
How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7

This short howto will explain the steps to reset a lost root password or to reset a forgotten root password on Linux RHEL 7 or CentOS 7. Basically, we will...

How to Update CentOS or Upgrade CentOS to the Latest Version
How to Update CentOS or Upgrade CentOS to the Latest Version

Recently, the latest version of CentOS 7.3 was released. All users of CentOS 7.0, 7.1 and 7.2 can upgrade their system to the most recent. This quick guide will explain...

How to Change your WordPress Username, Nickname and Display Name in MySQL
How to Change your WordPress Username, Nickname and Display Name in MySQL

After you create an account log in WordPress, you may want to change your WordPress username, as appropriate or due to security reason. However, you can not do this from...

How to Enable SSH Root Login on Ubuntu 16.04
How to Enable SSH Root Login on Ubuntu 16.04

As what we wrote in the previous article on how to allow SSH root on Ubuntu 14.04, after installing a fresh new copy of Ubuntu 16.04 LTS, we find that...

How to Change UUID of Linux Partition on CentOS 7
How to Change UUID of Linux Partition on CentOS 7

UUID (Universally Unique IDentifier) should be unique and it is used to identify storage devices on a linux system. If you cloned a virtual machine from vCenter, the metadata containing...

Leave a Reply

Your email address will not be published. Required fields are marked *