How to Test Posfix Mail Service using Telnet

Share this Article :

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 :

[[email protected] ~]# 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:<[email protected]>
250 2.1.0 Ok
RCPT TO:<[email protected]>
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:<[email protected]>
250 2.1.0 Ok
RCPT TO:<[email protected]>
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 :

[[email protected] ~]# 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.

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:<[email protected]>

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:<[email protected]>

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 :

[[email protected] ~]# 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=<[email protected]>
Jun  5 01:59:24 mail postfix/qmgr[4464]: 194869C1AB: from=<[email protected]>, size=409, nrcpt=1 (queue active)
Jun  5 01:59:25 mail postfix/cleanup[17117]: 52A7E9C1AD: message-id=<[email protected]>
Jun  5 01:59:25 mail postfix/smtp[17317]: 194869C1AB: to=<[email protected]>, 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.

[[email protected] ~]# 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=<[email protected]>
Jun  5 02:14:55 mail postfix/qmgr[4464]: 538BB9C1AD: from=<[email protected]>, size=408, nrcpt=1 (queue active)
Jun  5 02:15:05 mail postfix/cleanup[22300]: EDD0E9C1AE: message-id=<[email protected]>
Jun  5 02:15:05 mail postfix/smtp[22317]: 538BB9C1AD: to=<[email protected]>, 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

Leave a Reply