Testing email delivery

There is a newer issue of thie ISPmail guide available if you are using Debian Jessie!

By now you will have spent considerable time digging through configuration files and trying to understand new terms. And you may be worried whether all you did actually leads to a working mail server. So before we continue with the configuration let’s take a break and verify that all you did works so far.

At this point the /var/vmail directory should be empty yet. You can get a list of all files and directories within by running:

find /var/vmail

There is probably nothing except perhaps a “lost+found” directory if /var/vmail is on a separate partition.

If you added test data to the database in the section about database preparation as you were told then you have “example.org” configured as a virtual domain and “john@example.org” as a user in that domain. Open a new terminal window and run

tail -f /var/log/mail.log

to see what the mail server is doing. Now let’s send an email to John. A simple way to create and send an email is to pipe text to the “mail” command. Do that in another terminal window:

echo test | mail john@example.org

If all works as expected your mail.log will show a lot of technical information about the email delivery. Like this:

Oct 20 17:42:32 sirius postfix/pickup[22273]: A6F8EB55: uid=0 from=<root>
Oct 20 17:42:32 sirius postfix/cleanup[22582]: A6F8EB55: message-id=<20131020154232.A6F8EB55@sirius.localdomain>
Oct 20 17:42:32 sirius postfix/qmgr[22274]: A6F8EB55: from=<root@sirius.workaround.org>, size=287, nrcpt=1 (queue active)
Oct 20 17:42:32 sirius dovecot: auth-worker(22635): mysql( Connected to database mailserver
Oct 20 17:42:32 sirius dovecot: lda(john@example.org): msgid=<20131020154232.A6F8EB55@sirius.localdomain>: saved mail to INBOX
Oct 20 17:42:32 sirius postfix/pipe[22586]: A6F8EB55: to=<john@example.org>, relay=dovecot, delay=0.14, delays=0.04/0/0/0.1, dsn=2.0.0, status=sent (delivered via dovecot service)
Oct 20 17:42:32 sirius postfix/qmgr[22274]: A6F8EB55: removed

Your output will look slightly different. But focus on the parts that are printed in bold letters. They should be exactly the same in your log file. If everything worked as expected Postfix has accepted the email and forwarded it to Dovecot which in turn wrote the email in John’s maildir. Look again:

find /var/vmail

Dovecot has now created a directory structure for John and created several directories and extra files:


Your files may have slightly different numbers.

Access the email on disk using different methods

Shell style

So John finally has finally received a new email into his inbox (that I have highlighted in bold letters). Just open that file and take a look – it is just a standard email with headers and a body. On my system it reads:

Return-Path: <root@sirius.workaround.org>
Delivered-To: john@example.org
Received: by sirius.localdomain (Postfix, from userid 0)
id A6F8EB55; Sun, 20 Oct 2013 17:42:32 +0200 (CEST)
To: john@example.org
Message-Id: <20131020154232.A6F8EB55@sirius.localdomain>
Date: Sun, 20 Oct 2013 17:42:32 +0200 (CEST)
From: root@sirius.workaround.org (root)


If anything went wrong then carefully check the last lines of your /var/log/mail.log. It will very likely point you to the problem. Or read the troubleshooting section. Or just add a comment to this page and ask other readers for help.

(If you are curious how to send an email to your mail server using a manual SMTP session then read the respectivesection in the Lenny tutorial. It’s also good as an additional test because the “mail” command bypasses a few of Postfix’s security features.)

Mutt style

You can also use a slightly more comfortable tool to access Maildirs that will come handy for you as a mail server administrator: “mutt”.

mutt -f /var/vmail/example.org/john/Maildir

(You may get asked to create /root/Mail – this is standard procedure. Just press Enter.)

What you see now are the contents of John’s mailbox:

Press enter and you can read the email number 1:

So there is your test email. Press “q” to quit “mutt”.

IMAP style (mutt)

Actually we just cheated a little as we have accessed John’s inbox directly on disk. A better test is to use POP3 or IMAP. And fortunately “mutt” supports IMAP:

mutt -f imap://john@example.org@localhost

You may be prompted to confirm that you are connecting to a mail server with an untrusted SSL certificate. That’s okay. In the end you should see the index and email just like in the screenshots above. (The password is “summersun” – remember?) That worked? Great. Otherwise check your /var/log/mail.log for error messages.

The folder name looks a bit weird, doesn’t it. Let me explain it:

  • imap://
    The protocol
  • john@example.org
    The login name (as we use the email address as the user name, too)
  • @
    The seperator between the user name and the host name of the mail server
  • localhost
    The mail server

​Maybe it makes a bit more sense now. 🙂

If you still can’t get enough and want to run a manual POP3 and IMAP session using TELNET then check out the Lenny tutorial on a complete example.

IMAP style (Thunderbird)

Your users are not likely to use “mutt” to read their email – unless they are immortal console nerds. So of course you can use a graphical mail client to access John’s emails. If you use Thunderbird (or “icedove” on Debian) then feel free to configure a new email account using IMAP and connect to the server. Remember that the user name and email address are both “john@example.org” and the password is “summersun”.

POP3 versus IMAP

If you wonder what the difference between POP3 and IMAP is:

  • POP3 (Post Office Protocol) is a simple protocol that lets you fetch email from a single mailbox. It is usually used to collect all emails, though you can also leave them on the server but this is a bit of a hack and you can’t create multiple folders on the server to sort your mail. It saves space on the mail server because the email gets moved to the user’s hard disk on their computer. But they won’t be able to access the same email from another computer. Besides you cannot create multiple folders on the server to sort your mail. There is just the inbox. This variant is antiquated and not exactly user-friendly.
  • IMAP (Internet Messaging Application Protocol) is predominantly focused upon leaving your mail on the server but you can also collect it like POP3. The inbox is where your incoming emails are stored but users can also maintain folders and move emails to them. But users can move emails to different directories. IMAP is useful when you want to access your email from different locations without losing mail because you fetched it from another location. The drawback is that lazy users leave their mail on the server thus filling up your server’s hard disk (unless you use quotas).
Scroll to Top