We have several domains with MX records pointing at a gateway running Qmail that we have at the edge of the network, which in turn forwards it to one of several internal mail servers based on smtproutes.

My question is, if I wanted to forward every Email that came in for a specific domain to two separate servers, is there an easy way to do this in Qmail? (We would like to migrate from one machine to another without syncing IMAP accounts, so we want the mail to go to both machines for a few weeks so that users can have their recent mail on the new server).

Thank you.

PS, my apologies if this is a duplicate, I thought I submitted this but cannot find it now (not in my history either) so I figured it must have not gone through.


You may want to give a look at this: lifewithqmail.org/lwq.html#dot-forward
and this: greens.org/about/software/qmail/man/man5/dot-qmail.html

THE QMAIL FILE To change qmail-local's behavior, set up a .qmail file in your home directory.

      .qmail contains one or more lines.  Each line is a delivery
      instruction.  qmail-local follows each instruction in turn.
      There are five types of delivery instructions:  (1) comment;
      (2) program; (3) forward; (4) mbox; (5) maildir.

      (3)  A forward line begins with an ampersand:


           qmail-local takes the rest of the line as a mail
           address; it uses qmail-queue to forward the message to
           that address.  The address must contain a fully
           qualified domain name; it must not contain extra
           spaces, angle brackets, or comments:

                # the following examples are WRONG
                & me@new.job.com
                &me@new.job.com (New Address)

           If the address begins with a letter or number, you may
           leave out the ampersand:


           Note that qmail-local omits its new Return-Path line
           when forwarding messages.

Hope this helps - I don't have a qmail server handy to test this first.

You might need to use a script to create these files for each user.

  • Thanks, I will try to see if this can be incorporated into our setup. – yayim Jan 29 '10 at 17:57

How many users are involved? Would it be possible to have them add another account to their email client to start pulling mail from the new server? If configured correctly, they'll still have access to their old mail (and can even move it to the new server if using IMAP for both accounts).

Also, why the reluctance to sync the IMAP accounts? Are you switching to a different IMAP server? When I've moved mail in the past, I've used rsync to get mail copied to the new server. After one rsync, stop IMAP/SMTP on the old server, do another rsync to get changes made during the first rsync, then start IMAP/SMTP on your new server.

Change configuration files so mail is directed to the new server instead of the old. Notify users in advance, and do it in the middle of the night. If you control your DNS you can lower the TTL on your host records a week in advance so when you actually make the change, the DNS update will propagate quickly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.