Postfix delivery to @domain and -domain

I am running into some issues with the configuration of Postfix. I can say I am mostly confused about it.

From searching the forums for 2 days and reading and rereading various posts I gather that Postfix does not like nor use the @ when it comes to email addresses. But, Joe and Jamie had come up with some sort of a solution to address the delivery of the mail to both user@doman and user-domain. To my understanding the virtualtable was supposed to resolve this. Postfix sees the table because it lists all of the accounts, and the @domain accounts are mapped to -domain. For some reason postfix does not deliver mail to both places, just to -domain.

This is my main.cf

[code:1]readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
relocated_maps = hash:/etc/postfix/relocated
sender_canonical_maps = hash:/etc/postfix/sender_canonical
recipient_canonical_maps = hash:/etc/postfix/recipient_canonical
canonical_maps = hash:/etc/postfix/canonical
virtual_alias_maps = hash:/etc/postfix/virtual
transport_maps = hash:/etc/postfix/transport
header_checks = regexp:/etc/postfix/header_checks[/code:1]

I have come across MailDir being mentioned at few different places on the forums. Silly question, but where do I config this. Isn’t this configured in the VMin when asked where to deliver the mail?

This is Virtuamin GPL on CentOS 5

I don’t think we’ve actually ever solved this for traditional mbox format mail spool files. You pretty much have to use Maildir (you ought to anyway…it’s just better).

Switching to Maildir happens in a couple of places, and depends on how you’re delivering mail.

If you’re delivering directly from Postfix, you set the “home_mailbox = Maildir/” in main.cf (you should do this even if you’re delivering via procmail, as Virtualmin uses it to figure out stuff, as well).

If you’re delivering via procmail, set the following:

DEFAULT=$HOME/Maildir/
ORGMAIL=$HOME/Maildir/

At the end of you procmailrc (changing existing DEFAULT and ORGMAIL fields, if they exist, obviously).

Finally, you may need to tell Dovecot where to find your mail. It tries to detect the location, and usually works fine…but if you’ve got old mbox mail spools laying around, or anything weird in your configuration it might get confused. You can set it with either the default_mail_env or mail_location directive (depends on the version of Dovecot you have).

If you haven’t switched Usermin over to using IMAP, then you’ll either need to configure it to use IMAP (which doesn’t care about location of mail) or tell it how to find mail in the new location. I believe Read Mail in Webmin will figure it out based on the configuration of Postfix, but I might be lying.

Thank you Joe.

This made things easier. Now I only see the @domain and not the -domain mailboxes in the Read Mail module.

I’ve looked at procmail, but I haven’t decided to use it yet. Still deciding.

Now I do not see the old emails. When using Maildir, do I just copy over the old emails or do I have to use some kind of a conversion method?

It’s a different format–merely copying over won’t work.

I think Jamie has built an mbox to Maildir converter into one of the migration tools for cPanel or Plesk or Ensim…yep, there’s a little snippet of code in the cPanel migration script to convert using the various mail libraries in Webmin. I’ll see about getting this turned into a standalone script in the future…maybe in the form of a complete “Switch me over to Maildir” script that’ll make sure all of the other bits are set correctly in Postfix, Dovecot, and Procmail (if being used).

In the meantime, there are some good scripts out on the web to make the change–conversion isn’t terribly complex, as they are both plain text formats with just a few bits of special data.

I believe this is the one I’ve always used:

http://untroubled.org/mbox2maildir

Though this one looks a lot nicer (but requires the TimeDate Perl module–though this is available in the repos of most modern Linux distros, I think, and if not you can use the Webmin CPAN modules module to install it):

http://batleth.sapienti-sat.org/projects/mb2md/

I think I’d probably go with mb2md if I were in your shoes today.

Thank you Joe. I will have to familiarize myself with them and try them out.