Plesk and Qmail into Virtualmin and Postfix

Biggest headache!

I’ve spent hours trying to get the Maildir storage of a Postfix install working on a Virtualmin box that had been migrated from Plesk.

There a few critical steps to get everything working. There are lots of references out there, but none covered all my issues at once. All these bits might need setting or just verifying to make it all happy, and this is done on a CentOS 5 box.
Ultra critical points for me were step 1 (6th line), step 6, step 7, step 9 and the last few command line instructions (especially the 1st line).

  1. Webmin -> Webmin -> Usermin Configuration -> Usermin Module Configuration -> Read mail
    Mail storage format for Inbox = Remote IMAP server
    Sendmail mail file location = /var/spool/mail
    Qmail or MH directory location = Subdirectory under home directory
    Qmail or MH directory in home directory = Maildir
    POP3 or IMAP server name = localhost (this might need to be typed explicitly)
    Sendmail command = /usr/lib/sendmail
    Default hostname for From: address = From real hostname
    Allow editing of From: address = yes
    From: address mapping file = /etc/postfix/virtual
    Address mapping file format = Address to username(virtusertable)
  2. Webmin -> Webmin Configuration -> Webmin Modules
    Install Postfix
    Remove Sendmail
  3. Webmin -> Servers -> Postix Mail Server -> General Options
    What domain to use in outbound mail = Use hostname
    What domains to receive mail for = $myhostname, localhost.$mydomain, localhost, localhost.localdomain
    Send outgoing mail via host = Deliver directly
    Default database type = hash
    Internet hostname of this mail system = Default (provided by system)
    Local internet domain name = Default (provided by system)
    Local networks = Default (all attached networks)
  4. Webmin -> Servers -> Postix Mail Server -> Mail Aliases
    Alias databases used by the local delivery agent = hash:/etc/aliases
    Alias databases built by “newaliases” command = hash:/etc/aliases
  5. Webmin -> Servers -> Postfix Mail Server -> Virtual Domains
    Domain mapping lookup tables = hash:/etc/postfix/virtual
    Domains to perform virtual mapping for = From domain mapping tables
  6. Webmin -> Servers -> Postfix Mail Server -> Local Delivery
    Home-relative pathname of user mailbox file = Maildir/
  7. Webmin -> Servers -> Procmail Mail Filter
    Set variable DEFAULT to $HOME/Maildir/
    Set variable ORGMAIL to $HOME/Maildir/
  8. Webmin -> Networking -> Networking Configuration -> Hostname and DNS Client
    Hostname = localhost.localdomain
  9. Webmin -> Networking -> Networking Configuration -> Host Addresses
    127.0.0.1 = localhost, localhost.localdomain
    <your external IP address> = <FQDN> (eg. 80.70.60.50 = example.com)
    Then click ‘Apply Configuration’

The last few steps are best done from the root command line…

hostname  (eg. hostname mail.example.com)
mkdir -p /etc/skel/Maildir/new mkdir -p /etc/skel/Maildir/cur mkdir -p /etc/skel/Maildir/tmp
wget -c http://www.qmail.org/convert-and-create
chmod +x convert-and-create
./convert-and-create
postmap /etc/postfix/virtual
newaliases
service postfix restart

Few extra pointers ..
you need

host `hostname`

to give you the <hostname.FQDN> and external IP address (take note of the backticks, not apostrophes)…

mail.example.com has address 80.70.60.50

and looking inside /etc/hosts, you should see the 2nd line as your external IP address and just the <FQDN>…

127.0.0.0.1   localhost   localhost.localdomain
80.70.60.50   example.com

You’re looking for the results of

postconf -n

to look something like this

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
mail_owner = postfix
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, localhost.localdomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
sample_directory = /usr/share/doc/postfix-2.3.3/samples
sender_bcc_maps = hash:/etc/postfix/bcc
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
unknown_local_recipient_reject_code = 550
virtual_alias_maps = hash:/etc/postfix/virtual

Anyway, hope that helps .. you can wake up and leave now if you like.

References:
http://bliki.rimuhosting.com/space/knowledgebase/linux/mail/Postfix+mbox+to+Maildir+conversion

http://bliki.rimuhosting.com/space/knowledgebase/linux/mail/postfix+notes

http://www.postfix.org/DEBUG_README.html

http://www.seaglass.com/postfix/faq.html

http://www.virtualmin.com/node/11123

2 thoughts on “Plesk and Qmail into Virtualmin and Postfix

  1. I just wanted to mention that most of this stuff happens automatically if you use the Virtualmin install.sh install script to setup Virtualmin. Of course, that only works reliably on a freshly installed and supported OS, but it does take away all of this drudgery and make it automatic and removes the opportunities for typos and other mistakes in configuration.

    One step missing here is setting up Procmail for spam and AV filtering with Virtualmin management (if you wanted it), though I think just turning off those features and turning them back on will do that without having to hit the command line again, though you do need procmail-wrapper from our software repositories for it to actually work.

    We’re happy you’re using Virtualmin! Don’t hesitate to hit us up in the forums if you run into any problems.

  2. @Joe,
    Thanks for visiting! I did this on an Amazon EC2 instance that I tweak every time I start a new machine up there. Originally I used the install.sh and it worked perfectly. Not exactly sure at which point the mail got hosed, but I think it was during the import of the Plesk backup. I now think the import set up mbox mail storage (as that was what Plesk was using) and as I wanted Maildir, I started fiddling with things and not keeping sensible track or making informed decisions :)

    Thanks for the heads up on SPAM and AV filtering management. I use ASL security suite from Atomicorp.. not sure if it’s a standard clamav, spamassassin setup that will work with Virtualmin .. any experience of that?

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>