Previous Section  < Day Day Up >  Next Section

Recipe 20.4. Testing the SMTP/POP3 Mail Server

20.4.1 Problem

You want to verify that the various server components are working.

20.4.2 Solution

Our old friend telnet and our new friend openssl s_client will do the job. Test the SMTP server with telnet:

$ telnet localhost 25

Trying 127.0.0.1...

Connected to localhost.localdomain.

Escape character is '^]'.

220 windbag.test.net ESMTP Postfix (Libranet/GNU)

ehlo windbag

250-windbag.test.net

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-XVERP

250 8BITMIME

mail from: foober@test.net

250 Ok

rcpt to: carla@test.net

250 Ok

data

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

Date: Jan 15, 2004

From: foober

Reply-to: foober@test.net

Message-ID: six

Subject: telnet test

Hi Carla,

Did you get this?

.

250 Ok: queued as 6069F2290C

quit

221 Bye

Connection closed by foreign host.

Also test plain, unencrypted POP3 with telnet:

$ telnet localhost 110

Trying 127.0.0.1...

Connected to localhost.localdomain.

Escape character is '^]'.

+OK Hello there.

user carla

+OK Password required.

pass sekritword

+OK logged in.

stat

+OK 2 1275

list

+OK POP3 clients that break here, they violate STD53.

1 638

2 637

.

retr 1

+OK 638 octets follow.

Return-Path: <stinkpad@test.net>

X-Original-To: carla@test.net

Delivered-To: carla@test.net

Received: from 192.168.1.100 (unknown [192.168.1.100])

 by windbag.test.net (Postfix) with ESMTP id 409E722884

 for <carla@test.net>; Thu, 15 Jan 2004 15:29:54 -0700 (PDT)

From: stinkpad <stinkpad@test.net>

To: carla@test.net

Subject: telnet test

Date: Thu, 15 Jan 2004 15:29:50 -0700

User-Agent: KMail/1.5.4

MIME-Version: 1.0

Content-Type: text/plain;

  charset="us-ascii"

Content-Transfer-Encoding: 7bit

Content-Disposition: inline

Message-Id: <200401151529.50714.stinkpad@test.net>

   

Hi Carla,

Did you get this?

   

.

quit

+OK Bye-bye.

Connection closed by foreign host.

Test TLS/SSL support with openssl s_client. Use the POP3 mail commands:

$ openssl s_client -connect localhost:995

CONNECTED(00000003)

depth=0 /C=US/ST=NM/L=Albuquerque/O=Courier Mail Server/OU=Automatically-generated POP3 SSL

key/CN=windbag/emailAddress=postmaster@test.net

verify error:num=18:self signed certificate

...

<many lines of certificate data and protocols>

---

+OK Hello there.

user carla

+OK Password required.

pass sekritword

+OK logged in.

Continue just as you would with any POP3 session.

You can test client connectivity by hostname or IP:

$ telnet windbag 25

$ telnet 192.168.1.5 110

$ openssl s_client -connect windbag:995

20.4.3 Discussion

Here are some of the more common POP3 commands:


list

Show a list of messages, by number, with the number of bytes in each message.


top msg lines

Display the message header of message msg and display lines many lines. For example, top 3 5 displays the headers of message 3 and the first 5 lines of the body of the message.


retr msg

Display the message, selected by number (e.g., retr 2).


dele n

Delete message number n.


rset

Undelete any messages that are marked for deletion.


quit

Delete messages marked for deletion, and log out.

20.4.4 See Also

  • RFC 1939 for a complete description of POP commands

  • This chapter's "Introduction," for a list of ports for the different mail protocols

  • telnet(1)

    Previous Section  < Day Day Up >  Next Section