Testing mail servers
- November 7th, 2008
- Posted in Linux
- Write comment
Back in the good ol’ days of POP3 it was really easy to test a mail server manually you just simply telnet to port 110 issue some 3 command and done! Now that all ISPs support IMAP things are a little more complicated. Here’s my little guide to manually testing POP3, IMAP and SMTP
Testing POP3
POP3 testing is really really simple, here’s an example (The command I entered are in bold):
[adam@desktop ~]$ telnet zippy.deaconsworld.org.uk 110
Trying 10.0.0.1...
Connected to zippy.deaconsworld.org.uk.
Escape character is '^]'.
+OK Dovecot ready.
user <username>
+OK
pass <password>
+OK Logged in.
list
+OK 185 messages:
1 34718
<snip>
185 20419
.
top 1 0
+OK
Return-path: <someone@example.com>
Envelope-to: <someonelse@example.com>
Delivery-date: Mon, 20 Oct 2008 15:02:43 +0100
Received: from outbound.mse17.exchange.ms ([64.71.238.253])
by zippy.deaconsworld.org.uk with esmtps (TLSv1:RC4-MD5:128)
(Exim 4.69)
(envelope-from <someone@example.com>;)
id 1KrvLE-0001Fq-PT
for <someonelse@example.com>; Mon, 20 Oct 2008 15:02:43 +0100
<snip>
.
quit
+OK Logging out.
Connection closed by foreign host.
Here’s a list of some useful commands and their explanations:
- user [username] - Sends the username for the connection
- pass [password] – Sends the password for the connection
- list – Displays a list of email ID and their sizes.
- top [id] [length] – Gets the “top” of an e-mail. The ID is from the list command (the first e-mail is always 1). top always gets the headers and then [length] lines e.g. top 1 0 will get just the headers of the first e-mail or top 2 10 will get the headers and the first 10 lines of e-mail 2.
- retr [id] – Gets the whole of e-mail.
- dele [id] – Deletes an e-mail
- quit – closes the connection
Testing IMAP
IMAP is a little more complicated because of folders and because it’s asynchronous. After telnetting to port 143, here’s an example:
[adam@desktop ~]$ telnet zippy.deaconsworld.org.uk 143 Trying 10.0.0.1... Connected to zippy.deaconsworld.org.uk. Escape character is '^]'. * OK Dovecot ready. 1 login <username> <password> 1 OK Logged in. 2 select "INBOX" * FLAGS (\Answered \Flagged \Deleted \Seen \Draft unknown-1 unknown-0 Junk receipt-handled NonJunk $MDNSent) * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft unknown-1 unknown-0 Junk receipt-handled NonJunk $MDNSent \*)] Flags permitted. * 185 EXISTS * 0 RECENT * OK [UNSEEN 183] First unseen. * OK [UIDVALIDITY 1220688986] UIDs valid * OK [UIDNEXT 3859] Predicted next UID 2 OK [READ-WRITE] Select completed. 3 FETCH * ALL * 185 FETCH (FLAGS () INTERNALDATE "07-Nov-2008 09:51:29 +0000"... 3 OK Fetch completed. 4 logout * BYE Logging out 4 OK Logout completed. Connection closed by foreign host.
Here you’ll notice the numbers at the start of each line. This technically should be a unique string for each command, the server will reply with the same number. In reality, you can use the same number for each line. As before here’s a list of useful commands you might need:
- LOGIN “[username]” “[password]“ – sends the username/password
- SELECT “[folder]“ – Selects the folder to use. I always use INBOX as this should always exist
- FETCH * ALL – Gets all the heads for the first message
- LOGOUT – Closes the connection
Testing SMTP
Just for completness here’s a test for SMTP. After telnetting to port 25, try the following:
[adam@desktop ~]$ telnet zippy.deaconsworld.org.uk 25 Trying 10.0.0.1... Connected to zippy.deaconsworld.org.uk. Escape character is '^]'. 220 zippy.deaconsworld.org.uk ESMTP Exim 4.69 Fri, 07 Nov 2008 11:18:45 +0000 ehlo adam 250-zippy.deaconsworld.org.uk Hello adam [10.0.0.28] 250-SIZE 52428800 250-PIPELINING 250-AUTH LOGIN 250-STARTTLS 250 HELP mail from: adam@deaconsworld.org.uk 250 OK rcpt to: adam@deaconsworld.org.uk 250 Accepted data 354 Enter message, ending with "." on a line by itself Subject: test test . 250 OK id=1KyPMm-00078C-9u quit 221 zippy.deaconsworld.org.uk closing connection Connection closed by foreign host.
The above should send a test message, however it’s not exactly RFC2822 complient so don’t be surprised if spam filters drop it.
No comments yet.