Right, now we're ready to test things out! First, let's look at mailbox delivery. In fact we have to deliver at least one mail into each mailbox to create its directory structure, before we can access it using pop3 or imap.
Here's one way to do it: we can invoke Exim, Linnet's mail transport agent, directly from the command line to test whether an address is valid and to perform a delivery to a mailbox. In the latter case you have to type the message directly in, line by line, ending with ctrl-D or a dot on a line of its own.
# linnet exim -bt fred@example.com Maildir directory: /var/linnet/mail/6/25/fred%40example.com/Maildir fred@example.com router = maildir, transport = maildir_delivery # linnet exim -v -odf fred@example.com Subject: test this is a test . LOG: MAIN <= root@billdog.local.linnet.org U=root P=local S=381 delivering 1DBBO8-0000wC-El Maildir directory: /var/linnet/mail/6/25/fred%40example.com/Maildir LOG: MAIN => fred@example.com F=<root@billdog.local.linnet.org> P=<root@billdog.local.li nnet.org> R=maildir T=maildir_delivery S=503 QT=4s DT=0s LOG: MAIN Completed
Another way to do it is by connecting to the SMTP daemon on port 25 and submitting a mail over TCP/IP, in the same way that incoming messages are received over the Internet. After the 'data' command, the message is terminated by a single dot on a line of its own.
# telnet 127.0.0.1 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 billdog.local.linnet.org (localhost [127.0.0.1]:25) ESMTP Exim 4.50+Linnet+0 .4.0 Tue, 15 Mar 2005 12:47:16 +0000 ehlo test 250-billdog.local.linnet.org Hello localhost [127.0.0.1] 250-SIZE 52428800 250-PIPELINING 250 HELP mail from:<> 250 OK rcpt to:<wilma@example.com> 250 Accepted data 354 Enter message, ending with "." on a line by itself subject: test this is a test . 250 OK id=1DBBSK-0000wa-Ek quit 221 billdog.local.linnet.org closing connection Connection closed by foreign host.
In this case you don't actually see the delivery taking place, but you can find it in Exim's log files:
# tail /var/linnet/exim/log/mainlog ... 2005-03-15 12:47:35 +0000 1DBBSK-0000wa-Ek <= <> H=localhost (test) [127.0.0.1]: 51793 I=[127.0.0.1]:25 P=esmtp S=258 for wilma@example.com 2005-03-15 12:47:35 +0000 1DBBSK-0000wa-Ek => wilma@example.com F=<> P=<> R=mail dir T=maildir_delivery S=352 QT=7s DT=0s 2005-03-15 12:47:35 +0000 1DBBSK-0000wa-Ek Completed &prompt;
If example.com were a real domain,
and you set up the domain name system with an MX record
pointing at your Linnet box, people on the Internet could
now send mail to <fred@example.com>
and <wilma@example.com>,
and it would arrive in their mailboxes.
You can of course test POP3 and IMAP access by pointing a mail client at your new mailserver, but it's a much better test to connect to it directly on port 110 (POP3) or port 143 (IMAP) and login directly. This eliminates any uncertainty that there may be an issue with your client program, and in any case gives more useful debugging information if there is a problem.
# telnet localhost 110 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. +OK Hello there. user fred@example.com +OK Password required. pass wibble -ERR Temporary problem, please try again later
Oops, what happened there? Well, you can check the logs. The POP3 and IMAP daemons use 'syslog' to record their data. Depending on how your system is set up, mail logs probably go to /var/log/maillog.
# tail /var/log/maillog ... Mar 15 12:55:58 billdog pop3d: authdaemon: s_connect() failed: Connection refused Mar 15 12:55:58 billdog pop3d: [Hint: perhaps authdaemond is not running?] Mar 15 12:55:58 billdog pop3d: LOGIN FAILED, user=fred@example.com, ip=[127.0.0.1] Mar 15 12:55:58 billdog pop3d: authentication error: Connection refused
Aha, now we see the problem: the courier-imap packages have a separate authentication daemon whose job it is to validate passwords, and it's not running. So we simply have to start it and try again:
# linnet start authdaemon
authdaemon: running (pid 3666)
# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Hello there.
user fred@example.com
+OK Password required.
pass wibble
+OK logged in.
stat
+OK 1 515
retr 1
+OK 515 octets follow.
Return-path: <root@billdog.local.linnet.org>
Envelope-to: fred@example.com
Delivery-date: Tue, 15 Mar 2005 12:43:12 +0000
Received: from root by billdog.local.linnet.org (localhost)
with local id 1DBBO8-0000wC-El (Exim 4.50) for fred@example.com
(return-path <root@billdog.local.linnet.org>); Tue, 15 Mar 2005
12:43:12 +0000
Subject: test
Message-Id: <E1DBBO8-0000wC-El@billdog.local.linnet.org>
From: Charlie Root <root@billdog.local.linnet.org>
Date: Tue, 15 Mar 2005 12:43:10 +0000
this is a test
.
quit
+OK Bye-bye.
Connection closed by foreign host.
&prompt;
That's good. IMAP commands are different, but can still be given using telnet. Note that every command must be prefixed with a "tag", which is an arbitrary sequence of characters, and a space. In this example I have used "a" as the tag.
# telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THRE
AD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyr
ight 1998-2005 Double Precision, Inc. See COPYING for distribution information.
a login wilma@example.com boing
a OK LOGIN Ok.
a select inbox
* FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)
* OK [PERMANENTFLAGS (\* \Draft \Answered \Flagged \Deleted \Seen)] Limited
* 1 EXISTS
* 1 RECENT
* OK [UIDVALIDITY 1110891662] Ok
* OK [MYRIGHTS "cdilrsw"] ACL
a OK [READ-WRITE] Ok
a fetch 1 rfc822
* 1 FETCH (RFC822 {362}
Return-path: <>
Envelope-to: wilma@example.com
Delivery-date: Tue, 15 Mar 2005 12:47:35 +0000
Received: from localhost ([127.0.0.1]:51793 helo=test)
by billdog.local.linnet.org (localhost [127.0.0.1]:25)
with esmtp id 1DBBSK-0000wa-Ek (Exim 4.50) for wilma@example.com
(return-path <>); Tue, 15 Mar 2005 12:47:35 +0000
subject: test
this is a test
)
a OK FETCH completed.
a logout
* BYE Courier-IMAP server shutting down
a OK LOGOUT completed
Connection closed by foreign host.