Ubuntu – Postfix not delivering email using Maildir

maildirpostfixUbuntu

I've followed this guide to get postfix set up. I've not completed it yet, as from sending test emails, email is no longer being delivered since switching to Maildir from mbox.

I have created a Maildir directory with cur, new and tmp sub directories.

~$ ll
drwxrwxr-x 5 greg greg    4096 2012-07-07 16:40 Maildir/
~$ ll Maildir/
drwxrwxr-x 2 greg greg 4096 2012-07-07 16:40 cur
drwxrwxr-x 2 greg greg 4096 2012-07-07 16:40 new
drwxrwxr-x 2 greg greg 4096 2012-07-07 16:40 tmp

Send a test email.

~$ netcat mail.example.com 25
220 ubuntu ESMTP Postfix (Ubuntu)
ehlo example.com
250-ubuntu
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from: root@example.com
250 2.1.0 Ok
rcpt to: greg@example.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject: test email

Hi,
Just testing.
.
250 2.0.0 Ok: queued as 56B541EA53
quit
221 2.0.0 Bye

Check the mail queue.

~$ mailq
Mail queue is empty

Check if mail has been delivered.

~$ ls -l Maildir/new
total 0

Some postfix settings:

~$ sudo postconf home_mailbox
home_mailbox = Maildir/
~$ sudo postconf mailbox_command
mailbox_command =

/var/log/mail.log

Jul  7 16:57:33 li305-246 postfix/smtpd[21039]: connect from example.com[178.79.168.xxx]
Jul  7 16:58:14 li305-246 postfix/smtpd[21039]: 56B541EA53: client=example.com[178.79.168.xxx]
Jul  7 16:58:33 li305-246 postfix/cleanup[21042]: 56B541EA53: message-id=<20120707155814.56B541EA53@ubuntu>
Jul  7 16:58:33 li305-246 postfix/qmgr[20882]: 56B541EA53: from=<root@example.com>, size=321, nrcpt=1 (queue active)
Jul  7 16:58:33 li305-246 postfix/smtp[21043]: 56B541EA53: to=<greg@example.com>, relay=none, delay=30, delays=30/0.01/0/0, dsn=5.4.6, status=bounced (mail for example.com loops back to myself)
Jul  7 16:58:33 li305-246 postfix/cleanup[21042]: 1F68B1EA55: message-id=<20120707155833.1F68B1EA55@ubuntu>
Jul  7 16:58:33 li305-246 postfix/bounce[21044]: 56B541EA53: sender non-delivery notification: 1F68B1EA55
Jul  7 16:58:33 li305-246 postfix/qmgr[20882]: 1F68B1EA55: from=<>, size=1999, nrcpt=1 (queue active)
Jul  7 16:58:33 li305-246 postfix/qmgr[20882]: 56B541EA53: removed
Jul  7 16:58:33 li305-246 postfix/smtp[21043]: 1F68B1EA55: to=<root@example.com>, relay=none, delay=0, delays=0/0/0/0, dsn=5.4.6, status=bounced (mail for example.com loops back to myself)
Jul  7 16:58:33 li305-246 postfix/qmgr[20882]: 1F68B1EA55: removed
Jul  7 16:58:36 li305-246 postfix/smtpd[21039]: disconnect from domain.me[178.79.168.xxx]
Jul  7 17:10:38 li305-246 postfix/master[20878]: terminating on signal 15
Jul  7 17:10:39 li305-246 postfix/master[21254]: daemon started -- version 2.8.5, configuration /etc/postfix

Any ideas?

Best Answer

Your problem has nothing to do with maildir, and everything to do with bad mail routing. The key is the error message "mail for domain.com loops back to myself". You've setup MX records such that mail for domain.com points to your own mail server, but you haven't configured said mail server to actually accept and deliver mail. Set mydestination (or the corresponding virtual mail config, if that's your bag) to include domain.com, and all will be well.