Testing email delivery

So far you have spent considerable time with theory and configuration. Are you worried whether all you did actually leads to a working mail server? Before we do the final steps let’s take a break and verify that all you did works so far.

At this point the /var/vmail directory should be empty or maybe contain an “example.org” directory if you played with the john@example.org account previously. You can get a list of all files and directories within by running:

find /var/vmail

There may be nothing except perhaps a “lost+found” directory if /var/vmail is on a separate partition. And perhaps skeleton files like “.profile” or “.bashrc”.

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.

Send a test email

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:

Nov 8 22:29:40 jessie postfix/pickup[26781]: D663322AF9: uid=0 from=<root>
Nov 8 22:29:40 jessie postfix/cleanup[26854]: D663322AF9: message-id=<20151108222940.D663322AF9@debian-jessie.vagrantup.com>
Nov 8 22:29:40 jessie postfix/qmgr[21866]: D663322AF9: from=<root@debian-jessie.vagrantup.com>, size=313, nrcpt=1 (queue active)
Nov 8 22:29:40 jessie dovecot: lmtp(26859): Connect from local
Nov 8 22:29:40 jessie dovecot: lmtp(26859, john@example.org): 4xrmNdTMP1braAAACYsm4Q: sieve: msgid=<20151108222940.D663322AF9@debian-jessie.vagrantup.com>: stored mail into mailbox 'INBOX'
Nov 8 22:29:40 jessie postfix/lmtp[26858]: D663322AF9: to=<john@example.org>, relay=debian-jessie.vagrantup.com[private/dovecot-lmtp], delay=0.06, delays=0.02/0/0.01/0.02, dsn=2.0.0, status=sent (250 2.0.0 <john@example.org> 4xrmNdTMP1braAAACYsm4Q Saved)
Nov 8 22:29:40 jessie dovecot: lmtp(26859): Disconnect from local: Successful quit
Nov 8 22:29:40 jessie postfix/qmgr[21866]: D663322AF9: 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. If you get any errors in the log file then try to understand the error message and find the cause of the problem before you proceed.

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. That’s okay. The line printed in bold letter depicts the actual email file. It is the only file in the “new” folder.

Access the email as a file

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@ispmail-jessie.pmd.local>
Delivered-To: john@example.org
Received: by ispmail-jessie.pmd.local (Postfix, from userid 0)
 id 54FF0260EB4; Wed, 21 Oct 2015 12:23:37 +0200 (CEST)
To: john@example.org
Message-Id: <20151021102337.54FF0260EB4@ispmail-jessie.pmd.local>
Date: Wed, 21 Oct 2015 12:23:37 +0200 (CEST)
From: root@ispmail-jessie.pmd.local (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.

Access the email from your disk using mutt

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”.

This is a simple method to access mail directories on disk to trace problems.

Access the email through IMAP using 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 if you generated a self-signed certificate. 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 parameter after the “-f” looks a bit weird, doesn’t it. Let me explain it:

  • imap://
    The protocol. You can also use “imaps” but mutt automatically switches to imaps here.
  • 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

Access the email through IMAP using a desktop mail client

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”.

Access the email through Roundcube webmail

And last but not least you have a very easy way to access John’s emails by just using your web browser. After all you installed Roundcube earlier. So go to https://YOUR.MAIL.SERVER/ and login as “john@example.org” with password “summersun”. That should take you to the inbox:


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).

60 thoughts on “Testing email delivery”

  1. Hi,

    thank you very much for your guides.

    Some differences I encountered (on Debian Jessie):

    1. “/var/vmail” is not empty if you set up and test roundcube in the step before:

    > root@lando:~# ls -lh /var/vmail/
    > insgesamt 4,0K
    > drwx—— 3 vmail vmail 4,0K Nov 2 17:14 example.org

    2. After executing

    > tail -f /var/log/mail.log

    I get the following error in “/var/log/mail.log”:

    > Nov 3 11:10:00 lando postfix/pipe[34476]: 9BADF4275F: to=, relay=dovecot, delay=0.66, delays=0.43/0.01/0/0.22, dsn=4.3.0, status=deferred (temporary failure. Command output: lda: Error: user john@example.org: Error reading configuration: Invalid settings: postmaster_address setting not given lda: Fatal: Internal error occurred. Refer to server log for more information. )

    Dovecot configuration:

    > root@lando:~# doveconf | grep postmaster
    > postmaster_address =

    I uncommented “postmaster_address” in “/etc/dovecot/conf.d/15-lda.conf” and set it to my own email address, restarted dovecot, and the queued message got delivered instantly.

    1. Christoph Haas

      Thanks for your thoughts.

      (1) you are right – I made that clearer on this page.

      (2) This one is a bit strange. I didn’t need to set the postmaster_address in my test installation and still haven’t seen that error message. I would not like to set it manually because the default is “postmaster@. %d expands to recipient domain” which makes the most sense. Has anyone else seen this error message?

      1. i dont have this set in my 15-lda.conf so i am unsure as to why this error appeared for ck.

      2. Robert Maurer

        I am seeing this error message:

        Nov 15 04:45:06 cloud postfix/pickup[20581]: 968DB2523D: uid=1000 from=
        Nov 15 04:45:06 cloud postfix/cleanup[20739]: 968DB2523D: message-id=
        Nov 15 04:45:06 cloud postfix/qmgr[1158]: 968DB2523D: from=, size=295, nrcpt=1 (queue active)
        Nov 15 04:45:06 cloud dovecot: lmtp(20744): Fatal: Error reading configuration: Invalid settings: postmaster_address setting not given
        Nov 15 04:45:06 cloud postfix/lmtp[20743]: 968DB2523D: to=, relay=cloud[private/dovecot-lmtp], delay=0.05, delays=0.02/0.01/0.02/0, dsn=4.4.2, status=deferred (lost connection with cloud[private/dovecot-lmtp] while receiving the initial server greeting)

        1. Christoph Haas

          The LMTP module doesn’t have a postmaster address setting. Strange. Please run a “grep -r postmaster_address /etc/dovecot” and see what comes up. I just have it in 15-lda.conf and it’s commented out. There’s no postmaster_address setting defined anywhere here and I don’t get that error.

          1. Robert Maurer

            Same as you…
            /etc/dovecot/conf.d/15-lda.conf:#postmaster_address =

          2. Same here…

            As i don’t like a “static” solution (cause of several domains) i tried the following and it seem to work:

            postmaster_address = postmaster@%d

          3. Same postmaster issue here. Maybe include as a change to 15-lda.conf in in the manual?

        2. Pedro Barrio

          I see the same postmaster error and the message doesn’t deliver. Fixed in the “/etc/dovecot/conf.d/15-lda.conf” file with value “postmaster@%d” too.

  2. Hey…

    one more thing: `mail` could not be found when running `echo test | mail john@example.org`

    I installed `bsd-mailx` which works fine. Just curious what do recommend? (You did not mention a MUA in your “software packages” overview, or?)

    1. Christoph Haas

      Hi Jim. For some reason the “bsd-mailx” package was installed on all my systems. Looking at my /var/log/dpkg.log it got pulled in when the system installed Exim during the base installation. Did you install your system from another source than a bare Debian Jessie installation medium?

  3. Frederik Vanrenterghem

    Small one – you actually have to install mailutils in order to get the mail command.

  4. Hi, lovley tutorial but I must have slipped somewhere.

    Jan 2 02:25:47 ernie postfix/lmtp[1435]: 5AA5040E29: to=, relay=none, delay=0.06, delays=0.04/0.02/0/0, dsn=4.4.1, status=deferred (connect to ernie.xxxxx.xx[private/dovecot-lmtp]: No such file or directory)

    Any ideas? Clean install and I thought that I had made everything by the book.

    1. Christoph Haas

      @Bosse: Check your /etc/dovecot/conf.d/10-master.conf. I assume that you have something missing in your “service lmtp { unix_listener /var/spool/postfix/private/dovecot-lmtp … }”. Re-read the “Making Postfix send emails to Dovecot” page.

    2. Thanks a lot for your tutorial!

      I also had status=deferred (connect to [private/dovecot-lmtp]: No such file or directory) , and earlier noted that the file dovecot-lmtp was not created.
      https://serverfault.com/questions/512219/dovecot-lmtp-does-not-exist gave someone with the same symptoms and in my case the same cause: lmtp is defined under conf.d/ , but not in dovecot.conf.

      grep -r protocol /etc/dovecot pointed me at the inconsistency.

      I am not sure I should leave the protocols-entry in dovecot.conf; for the time being it seems OK to have a double (and consistent) declaration.

  5. Victor Andersson


    I get an error: No such file or directory

    Seems like the problem should be in 10-master.conf when i look at previous comments. However i cant seem to find something wrong with it.

    Here is a copy of that section taken from my configuration file.
    service lmtp {
    unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0600
    user = postfix
    Is anything wrong with it or is the problem else where?

    1. Victor Andersson

      My mistake. There was a } to much. For anyone else dovecot -n is a useful tool to find error in the config.

      service lmtp {
      unix_listener /var/spool/postfix/private/dovecot-lmtp {
      group = postfix
      mode = 0600
      user = postfix

      # Create inet listener only if you can’t use the above UNIX socket
      #inet_listener lmtp {
      # Avoid making LMTP visible for the entire internet
      #address =
      #port =

  6. Dear all, and Christoph in particular,

    I got stuck on the passwords for a few days, and I think I did not yet crack the nut.

    As a backend I use Postgres, and all seems fine while configuring while replacing the bits in the program- and plugin-names. Inserting regular records into the database is no problem either, and mails are recieved just fine.

    Login per imap fails though: Invalid password in passdb: crypt() failed: Invalid argument
    At first I thought to enter the encrypted and salted password while inserting users using some function, and took the Roundcube-query as an example. The syntax is not working for me, and I am not sure (=not the faintest idea) how to modify it for pgsql.

    In the end I ran ‘doveadm pw -s SHA256-CRYPT’ once, and started out with the same password for each user (sorry, users). I defined the column as bytea, and to insert the result from the cli, I cast the text value as bytea, like this (I hope it’s readable as comment):

    insert into virtual_users (vu_id, vd_id, password, email_address)
    select *
    from ( values ( 1, 2,cast (‘{SHA256-CRYPT}$5$C/YAWajo9QLpSmdA$W63d5ZjdUk3aE4ycPplDY1uIh2IZ1.V7n8yNJSgilf6′ as bytea),’boudewijn@’ ||(select name from virtual_domains where vd_id = 2) )
    ) as virtual_users ( vu_id
    , vd_id
    , password
    , email_address
    There are many useful pointers, and SELECT digest(‘my_password’, ‘sha256’) gives some hash, but in this way always the same value.
    Since the salt changes the output each run, I have no idea how to check whether my result is actually near the requested value (my knitted together result is always different, not helped by finding base64, hex and differently coded examples).

    Once it works, I’d also like to allow password changes via Roundcube. I tried finding out how to use pgsql with salted sha256 (based on the tutorial for mysql), but the results I found are not close enough for me to translate the mysql-queyr to the corresponding pgsql-query.

    pgcrypto is installed for the mail-database.

    Thanks in advance!

  7. I’m not completely there yet, but after testing with another table and a plain text column for the password, things look much better 🙂
    So for anyone else out there: in case you use pgsql, don’t set the password column as bytea (I must have mixed resources on safe password hashes in the database with other encryption-releated howtos).

    The password-update-query via the web may not yet work, but after successfully logging into the test-account with mutt I could login with roundcube and kmail as well. Great! 🙂

  8. Mike Booth

    Howdy Christoph,

    You might want to add settings to main.cf for opportunistic TLS encryption when Sending mail. I ran across this when sending test messages to my Gmail account. Gmail warned me with a red lock icon saying the messages were being sent unencrypted. My revised settings using an unsigned cert:

    # Receive TLS
    smtpd_use_tls = yes
    smtpd_tls_security_level = may
    smtpd_tls_loglevel = 1
    smtpd_tls_received_header = yes

    # Send TLS
    smtp_tls_security_level = may
    smtp_tls_loglevel = 1


  9. I get the following error message when testing mail delivery on Debian Jessie

    “echo test | mail john@example.org

    debian.domain.org[private/dovecot-lmtp]: No such file or directory)

    So LMTP setup from this tutorial does not seem to work.

  10. For me it works only partial. Most certainly this is my fault for trying to merge my old configuration into it, but I don’t see what I did wrong.

    First I had a working configuration of Postfix/Dovecot on an older Debian version (I think Squeeze but could also been Lenny) which did not use virtual hosts. I recently had to install my Debian new and have used Jessie for it. For configuring Postfix/Dovecot I used a backup of my old working configuration and another tutorial, which did not work for me (mainly problems with the Dovecot configuration). After searching for another tutorial I found this one. I reverted most of the changes I had made with the other tutorial, but I am sure I missed some, which are not at the default settings anymore, when I started this tutorial.

    Most of the tutorial works to this point. I also got the error on postmaster_address which I resolved by adding the according line. Also I got a warning, that I am not allowed to use the domain set in mydestination in both mydestination and virtual_mailbox_domains. I resolved this, by defining mydestination empty.

    I have already replaced the example.org testdata with correct data, I want to use on my mailserver. I can receive and send mails using roundcube and I can receive Mails on my Mail client on another machine using IMAP. However I currently can’t send mails from the client on another machine, to a receipient on the same virtual domain (this works with roundcube).

    I can’t figure out, what I have configured wrong. If I set my E-Mail-Client to use STARTTLS for sending the mail, I get the following error in the mail.log:
    postfix/submission/smtpd[3786]: warning: unknown[]: SASL
    PLAIN authentication failed:

    If I use SSL/TLS (which is the correct setting for receiving mail), I get a timeout on sending the mail from the client. In mail.log I get the error:
    postfix/submission/smtpd[5186]: lost connection after UNKNOWN from

    I think this is a postfix problem and none of dovecot, so I will only post my postfix configuration. If any configurations from dovecot are needed, just ask and I will post them. My main.cf:
    My master.cf:

    I will appreciate any hints in the right direction

    1. Of course! Because Google doesn’t help and I don’t have any clue how to find the error I post it in this comment section. And as soon as I have posted it, I find the solution.

      So using STARTTLS was the right setting and it is important to use the correct username. In my case, the username was simply username (which worked in my old configuration), but the new one needs username@domain.

  11. This is a great guide, thanks. Im having abit of trouble. I get this error, yet it seems to still send the mail. I didn’t do the apache/dovecot/phpmyadmin parts.

    Aug 13 16:08:44 JAHDebian postfix/pickup[16244]: 9AC761E0514: uid=0 from=
    Aug 13 16:08:44 JAHDebian postfix/cleanup[16983]: 9AC761E0514: message-id=
    Aug 13 16:08:44 JAHDebian postfix/qmgr[9342]: 9AC761E0514: from=, size=263, nrcpt=1 (queue active)
    Aug 13 16:08:44 JAHDebian dovecot: lmtp(16988): Connect from local
    Aug 13 16:08:44 JAHDebian dovecot: auth-worker(16993): Warning: mysql: Query failed, retrying: Table ‘mailserver.users’ doesn’t exist
    Aug 13 16:08:44 JAHDebian dovecot: auth-worker(16993): Error: pam(john@example.org): User query failed: Table ‘mailserver.users’ doesn’t exist (using built-in default user_query: SELECT home, uid, gid FROM users WHERE username = ‘%n’ AND domain = ‘%d’)
    Aug 13 16:08:44 JAHDebian dovecot: lmtp(16988, john@example.org): M4GeKOwpr1dcQgAAY0yi0w: msgid=: saved mail to INBOX
    Aug 13 16:08:44 JAHDebian postfix/lmtp[16987]: 9AC761E0514: to=, relay=JAHDebian[private/dovecot-lmtp], delay=0.13, delays=0.04/0.01/0.02/0.06, dsn=2.0.0, status=sent (250 2.0.0 M4GeKOwpr1dcQgAAY0yi0w Saved)
    Aug 13 16:08:44 JAHDebian postfix/qmgr[9342]: 9AC761E0514: removed
    Aug 13 16:08:44 JAHDebian dovecot: lmtp(16988): Disconnect from local: Successful quit

    1. btw, when i cat the reply i get this:

      Received: from JAHDebian
      by JAHDebian (Dovecot) with LMTP id /cLgCdUnr1dAQgAAY0yi0w
      for ; Sat, 13 Aug 2016 15:59:49 +0200
      Received: by JAHDebian (Postfix, from userid 0)
      id 253F81E5967; Sat, 13 Aug 2016 15:59:49 +0200 (CEST)
      To: john@example.org
      Date: Sat, 13 Aug 2016 15:59:49 +0200 (CEST)
      From: root@edbjan.dk (root)


      1. I solved this problem by doing 2 things:

        edit /etc/dovecot/dovecot-sql.conf.ext and insert the following:
        user_query = SELECT concat(‘/var/vmail/’, email) AS home, 5000 AS uid, 5000 AS gid FROM virtual_users WHERE email = ‘%u’

        edit /etc/postfix/main.cf and outcommenting the line:

        1. This is not the proper solution, if you’re implementing ISPMail

          This error is caused if you miss the part on the Setting Up Dovecot page about editing auth-sql.conf.ext and set userdb driver = static

  12. Holger Falkenstein

    Hi Christoph,

    thank you very much for that splendid tutorial.
    It helped me a lot to go through the setup process of a mail server.
    I do not want to run a “full” mail server, i will fetch mail from my provider with “getmail”, but i have setup my server according to your tutorial now.

    When i have set Dovecot and tried sending a mail from terminal, i was missing the “mail” command, too. I did apt-get install mailutils and now the mail command is there.

    But i am afraid i cant use the tail command as there is no mail.log file anywhere on my system it seems.
    I am using an Odroid C2 device with DietPi operating system. This should be a full Debian 8, adjusted to the needs of the arm-infrastructure.

    Can you help me find the place where dovecot is logging to, please ?

    Many thanks again for this great tutorial.


    1. Holger Falkenstein

      one thing to add:

      i can find all folders in /var/vmail/ for example.org and John 🙂
      (as i have used the sample data in the database)
      All interim testing that you provide within the different pages have all worked.

      Running “echo test | mail john@example.org” does not return an error, but there is no mail in any of the folders in /var/vmail at all.

    2. Holger Falkenstein

      Hi Christoph,

      i am sorry to have bothered you with that. RTFM is the key here…… if i only had done it BEFORE.
      DietPi OS in standard setup does not produce any logfiles. But you can install full log file capability with just one click, which i will do tonight.

      Maybe i can then get a clearer picture of why mail isnt delivered. Sorry for all the hassle, please feel free to delete my entries here.

      1. Holger Falkenstein

        Hi all, hi Christoph,

        i did set the DietPi on my Odroid C2 to full log capability, it all works very nice and fine now.

        Thank you again for that wonderful tutorial, your writings made it possible for me to set up a working mail server.

  13. Thanks for the tutorial. It’s well written and it’s been helpful. However I could use some help. I am not getting any thing added to /var/vmail. I’ve checked my lmtp settings in 10-master.conf multiple times and it’s not working. Here is my dovecot -n settings:

    # 2.2.13: /etc/dovecot/dovecot.conf
    # OS: Linux 3.16.0-4-amd64 x86_64 Debian 8.6 ext4
    mail_location = maildir:/var/vmail/%d/%n/Maildir
    managesieve_notify_capability = mailto
    managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date ihave
    namespace inbox {
    inbox = yes
    location =
    mailbox Drafts {
    special_use = \Drafts
    mailbox INBOX.Junk {
    auto = subscribe
    special_use = \Junk
    mailbox INBOX.Trash {
    auto = subscribe
    special_use = \Trash
    mailbox Sent {
    special_use = \Sent
    mailbox “Sent Messages” {
    special_use = \Sent
    prefix =
    separator = .
    passdb {
    args = /etc/dovecot/dovecot-sql.conf.ext
    driver = sql
    plugin {
    sieve = ~/.dovecot.sieve
    sieve_dir = ~/sieve
    protocols = ” imap lmtp sieve pop3″
    service auth {
    unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0666
    user = postfix
    service lmtp {
    unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0600
    user = postfix
    ssl_cert = </etc/ssl/certs/klines.email.pem
    ssl_key = </etc/ssl/private/klines.email.pem
    userdb {
    args = /etc/dovecot/dovecot-sql.conf.ext
    driver = sql
    userdb {
    args = uid=vmail gid=vmail home=/var/vmail/%d/%n
    driver = static
    protocol lmtp {
    mail_plugins = " sieve"

  14. I was able to fix this issue but now I have another issue.

    How do I connect to my email account through either my desktop mail app?

    Do you have some base settings for IMAP and SMTP? Do I need to open up some ports for this?

  15. thank you again for this guide and i apologize for asking so many questions, but I’m afraid I’m stuck again.
    I got to the point of doing the email test
    echo test | mail john@example.org
    when i compare your log to mine, your log goes from postfix/qmgr to dovecot

    Nov 8 22:29:40 jessie postfix/qmgr[21866]: D663322AF9: from=, size=313, nrcpt=1 (queue active)
    Nov 8 22:29:40 jessie dovecot: lmtp(26859): Connect from local

    But my log never gets to dovecot, i get an error about not finding the user, which of course makes sense since it’s not looking in the right place.

    Jan 16 14:36:09 ms postfix/qmgr[1123]: 11A9D42946: from=, size=277, nrcpt=1 (queue active)
    Jan 16 14:36:09 ms postfix/local[1208]: 11A9D42946: to=, orig_to=, relay=local, delay=0.07, delays=0.04/0.02/0/0.01, dsn=5.1.1, status=bounced (unknown user: “1”)

    So i’ve gone back through the section about making sure postfix sends emails to Dovecot, and i can’t find anything.

    from /etc/dovecot/conf.d/10-master.conf
    service lmtp {
    unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0600
    user = postfix

    after setting 10-master.conf i ran postconf virtual_transport=lmtp:unix:private/dovecot-lmtp and confirmed that main.cf has virtual_transport = lmtp:unix:private/dovecot-lmtp now at the end of the file. I restarted the system, No change. How can i determine why it’s not going to dovecot?

    Thanks again!

      1. Brilliant. i read through that page before i started installing and never went back to it. Looks like i’ve got some changes to make, thanks again!

      2. I read through that page again and changed to
        mydestination = localhost
        I’m now getting a different error in that mail log, but it still seems unwilling to use dovecot
        Jan 16 18:51:46 ms postfix/smtp[1626]: CB07F42946: to=, orig_to=, relay=none, delay=0.03, delays=0.02/0/0/0, dsn=5.4.6, status=bounced (mail for ms.mydomain.com loops back to myself)

        This is from my main.cf, do you see anything else i should change?

        smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
        myhostname = ms.mydomain.com
        alias_maps = hash:/etc/aliases
        alias_database = hash:/etc/aliases
        myorigin = /etc/mailname
        mydestination = localhost
        relayhost =
        mynetworks = [::ffff:]/104 [::1]/128
        mailbox_command = procmail -a “$EXTENSION”
        mailbox_size_limit = 0
        recipient_delimiter = +
        inet_interfaces = all
        smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3
        virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
        virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
        virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf,mysql:/etc/postfix/mysql-email2email.cf
        virtual_transport = lmtp:unix:private/dovecot-lmtp

        postmap -q john@example.org mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
        returns a 1 instead of returning /var/vmail/example.org/john/Maildir

        1. Christoph Haas

          You are facing the problem from another direction. Your problem is “mail for ms.mydomain.com loops back to myself”.

          Human translation: Postfix wanted to send email to @ms.mydomain.com, asked the DNS for the MX record and found out that it points to itself.

          Cause: your mail server is (still) not accepting email or @ms.mydomain.com. You probably want it to be a virtual domain. But it is not listed as a virtual domain.

          1. i’m just not understand why it’s even sending to 1@ms.mydomain instead of john@example.org
            it’s looking at virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf and not finding john@example.org
            i changed main.cf and set
            virtual_mailbox_domains = example.org , ms.mydomain.com insteadof using the mysql file
            and tried again. this time it does go to dovecot, but it’s bouncing the email still. it’s not finding john@example.org.
            i think there might be an issue with my database files.
            postmap -q john@example.org mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
            this returns a 1, not the email address
            postmap -q example.org mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
            this also returns a 1 instead of returning the domain.
            postmap -q jack@example.org mysql:/etc/postfix/mysql-virtual-alias-maps.cf
            this does return john@example.org
            from mail.log now
            an 17 07:21:11 ms dovecot: lmtp(4191): Connect from local
            Jan 17 07:21:11 ms postfix/lmtp[4190]: 118AD4297E: to=, orig_to=, relay=jeff.com[private/dovecot-lmtp], delay=0.06, delays=0.02/0/0.01/0.02, dsn=5.1.1, status=bounced (host jeff.com[private/dovecot-lmtp] said: 550 5.1.1 User doesn’t exist: 1@ms.mydomain.com (in reply to RCPT TO command))
            Jan 17 07:21:11 ms dovecot: lmtp(4191): Disconnect from local: Successful quit

  16. Local Mail delivery is no longer working with this guide.
    Postfix just blindly forwards them to dovecot, which says the user isn’t valid. Not going to enter those anywhere in the database either, because only local system mail is allowed for those. Like Cron Reports, which are now being discarded…

    1. Joe – you say “Postfix just blindly forwards to Dovecot…” but the ‘big picture’ shows Postfix querying MySQL to determine if the user is a valid recipient (at least for incoming external mail).

      Is there anything in the logs which show it’s Dovecot rejecting local-local mail rather than Postfix? (sorry, complete newbie at Postfix and Mail Servers).

      1. I expected it to do that for non-local mail, not for local system delivery (which apparently the author doesn’t care about / use?)

        In any case, the log clearly state that postfix is querying dovecot, which consequently denies the email. Thing is, it shouldn’t even go to dovecot as far as I’m concerned. Then again I don’t really care too much of whether it goes through dovecot, as long as it gets delivered properly.

        Feb 4 14:15:01 host postfix/pickup[10502]: 89A8980D55: uid=1000 from=
        Feb 4 14:15:01 host postfix/cleanup[10608]: 89A8980D55: message-id=
        Feb 4 14:15:01 host postfix/qmgr[10080]: 89A8980D55: from=, size=713, nrcpt=1 (queue active)
        Feb 4 14:15:01 host dovecot: lmtp(10611): Connect from local
        Feb 4 14:15:01 host dovecot: auth: Debug: Loading modules from directory: /usr/lib/dovecot/modules/auth
        Feb 4 14:15:01 host dovecot: auth: Debug: Module loaded: /usr/lib/dovecot/modules/auth/libdriver_mysql.so
        Feb 4 14:15:01 host dovecot: auth: Debug: Read auth token secret from /var/run/dovecot/auth-token-secret.dat
        Feb 4 14:15:01 host dovecot: auth: Debug: master in: USER#0111#011crontest@myFQDN.tld#011service=lmtp
        Feb 4 14:15:01 host dovecot: auth-worker(10615): Debug: Loading modules from directory: /usr/lib/dovecot/modules/auth
        Feb 4 14:15:01 host dovecot: auth-worker(10615): Debug: Module loaded: /usr/lib/dovecot/modules/auth/libdriver_mysql.so
        Feb 4 14:15:01 host dovecot: auth-worker(10615): Debug: sql(crontest@myFQDN.tld): query: SELECT email AS user, passwd AS password FROM virtual_users WHERE email = ‘crontest@myFQDN.tld’;
        Feb 4 14:15:01 host dovecot: auth-worker(10615): sql(crontest@myFQDN.tld): unknown user
        Feb 4 14:15:01 host dovecot: auth: Debug: userdb out: NOTFOUND#0111
        Feb 4 14:15:01 host postfix/lmtp[10610]: 89A8980D55: to=, orig_to=, relay=host.provider.tld[private/dovecot-lmtp], delay=0.09, delays=0.02/0.01/0.02/0.04, dsn=5.1.1, status=bounced (host host.provider.tld[private/dovecot-lmtp] said: 550 5.1.1 User doesn’t exist: crontest@myFQDN.tld (in reply to RCPT TO command))
        Feb 4 14:15:01 host dovecot: lmtp(10611): Disconnect from local: Successful quit
        Feb 4 14:15:01 host postfix/cleanup[10608]: 9C9C080D59: message-id=
        Feb 4 14:15:01 host postfix/bounce[10616]: 89A8980D55: sender non-delivery notification: 9C9C080D59

        guess I’ll just have to get rid of this entire thing and go with the previous setup, which was using postfix as MDA… At least that one actually, you know, *worked*.

        There needs to be a way to say “hey this is from local system to local use, don’t care about it just dump it into the right place and be done with it”… That’s all I need really.
        Of course it would work if I were to include every system user in the SQL database, but then these email addresses would be world wide email addresses that could also receive email from external, which isn’t supposed to be the case. System users are not (supposed to) be actual valid email addresses from the outside world, but are perfectly fine (and actually required) to receive system mail from their cron jobs.

        1. Joe – see my fix below. Unfortunately probably not much help for your particular issue.

          Good Luck.

          1. in my case I have
            mynetworks=, PublicIPAddress

            myhostname is going to change to sub.myFQDN.tld once that record actually points to this system, which it doesn’t yet because it ain’t working yet…

  17. As with a few others – I’m trying to build a local (non internet connected) mailserver for a very small network.

    I’ve built two accounts: –

    I can log into both from RoundCube (so usernames, password and MySQL must be rightish?)

    with mydestination = localhost.local, localhost, mydomain.local then

    If I log on as adrian and send mail to roger the mail log includes status=bounced (unknown user: “roger”)

    if I remove mydomain.local from mydestination then I get a warning of a runaway loop

    Struggling here, shame as the rest of the tutorial to this point was excellent and worked first time

    1. OK – fixed – at least for me.

      Despite all the warnings (and I’m not really a system developer – just a tinkerer ;-} ) I’d not sorted out the differences between host name and domain name. As I wasn’t internet connected and only had one host and one domain I’d made them the same. In mitigation, it doesn’t help that all the examples use “example.org” or “example.com” without making it clear where they are being used as examples of host and of domain.

      Anyway – one relaxed bunny that my demo system stands a chance of working in a few weeks now that I have a domain of “demo.local” and a host of “demoserver.local”

  18. Regards “If all works as expected your mail.log will show a lot of technical information about the email delivery. Like this:” … “But focus on the parts that are printed in bold letters. They should be exactly the same in your log file”, the mail ID 4xrmNdTMP1braAAACYsm4Q should not be bold.

  19. Regards Jon’s reply 2017-01-03 at 20:25 “How do I connect to my email account through either my desktop mail app? Do you have some base settings for IMAP and SMTP?”.

    The IMAP settings I used successfully with icedove were port 143, STARTTLS and Normal password. One gotcha was in the the “Add Security Exception” window in which I wrongly clicked “Get Certificate” when “Confirm Security Exception” was not greyed out.

    At this point in Christoph’s procedure the SMTP server is not set up.

  20. I tried to send a test email and got this error message:

    Jun 25 17:38:14 phst postfix/trivial-rewrite[12704]: warning: do not list domain .com in BOTH mydestination and virtual_mailbox_domains
    Jun 25 17:38:14 phst postfix/smtpd[12701]: NOQUEUE: reject: RCPT from : 550 5.1.1 : Recipient address rejected: User unknown in local recipient table; from= to= proto=ESMTP helo=

      1. Found the solution(s):

        Make sure MySQL is COMMITTING your changes. In my case, even though autocommit was on, every time I disconnected from the db my user would disappear and mail delivery would fail. Entering COMMIT at the prompt after inserting a record seems to have worked (though it seemed to fail, once, too).

        Make sure your etc/aliases file has the right users in it. I didn’t think that file would even be relevant with virtual users and virtual aliases, but one of my delivery tests tried to go to a user that doesn’t even have a record in the db. Pointing all the aliases to the user I wanted helped.

        If, on restarting postfix, you get a warning about having your domain name in both mydestinations and virtual_hosts, you need to delete it from mydestinations.

        Last, you might try using $config[‘default_host’] = ‘tls://you.domain.tld’; in roundcube/config.inc.php if Roundcube is having trouble with imap-login.

  21. This could be (most likely is) a configuration error, but I had to use mutt -f /var/spool/user@domain.com rather than the expected vmail directory.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top