Our company just switched to a new email domain and wants to keep the old domain around for a year as they notify everyone about the change. The old email domain was on Exchange 2007 and the new email domain is on Google Apps. Everyone is 100% on Google Apps, and the Exchange server just forwards on emails.

I would like to replace the Exchange server (it's underpowered and a waste of resources just forwarding emails) with something lightweight, based around Postfix or another email server. It needs to do the following:

  1. Forward emails sent to old_domain.com to new_domain.com
  2. Autoreply to the sender that everyone's email has changed to new_domain.com

Is this possible with Postfix, and does anyone have documentation on how to do it? I know just enough Linux to be dangerous, so I want to be sure before I suggest this.


I expect you want to fake a bounce message on the old domain. I use Exim and their is a control to do this.

You will also want a clear bounce message that indicates that the email was accepted for delivery, but future messages should be sent to the new address.

Exim also allows for custom bounce messages in the aliases file. This can be used to specify the new address.

Postfix or exchange may have similar functionality.

EDIT: Exim documentation is quite good. See the specification chapter 40 (Access Control Lists) and Chapter 11 (String Expansions) for details related to your issue.

You could try an entry in the recipient ACL something like this:

    domains = old.example.com
    control == fakereject/User ${local_part}@old.example.com has moved \
          Your message has been forwarded to their new address.

Redirecting to your new server can be done by individual aliases, a redirect router (see chapter 22 section 3), or a rewrite rule (see chapter 31 Address rewiting) such as:

*@old.example.com      $1@new.example.net     T
  • Do you know of any documentation on how to do this? – zippy Apr 22 '11 at 3:25

I would do that with Postfix and Cyrus-Imapd. Postfix would just forward everything to cyrus-imapd, and then you can use a Sieve Filter to :

  1. Forward the email to the new recipient
  2. Send a notification to the sender

From the top of my head, I think you could do it like that:

if header :contains "to" "user@old_domain.com" {
        redirect "user@new_domain.com";
        reject "old_domain.com is not used anymore, please send your emails to new_domain.com";

The difficulty is that Sieve rules are defined for each user, so you need to create a set of rules for each of your user. But you can easily script it.

More information about Sieve in Cyrus-Imapd can be found here: http://wiki.linuxwall.info/doku.php/en:ressources:astuces:sieve


I am not sure if this is possible with Google Apps, but what I would do with a "normal" mail server is to let it handle the mails for the old domain as well, pointing the MX for the old domain to the new server and then configure the MTA accordingly.

  • Unfortunately, I can't do this in Google Apps without giving everyone an old_domain.com email address (in addition to their new_domain.com email address). It's way too confusing for most people unfortunately. – zippy Apr 14 '11 at 17:08

You can use a procmail and a postfix.

  • 3
    You really need to explain how to do it... – Rowland Shaw Jul 27 '17 at 19:13

Postfix can do this easily (we did something like this in postfix about 7 years ago, so I no longer have access to the very simple filter that we wrote).

I would recommend using an autoresponder (see http://www.postfix.org/addon.html for a few examples) to generate the the autoreply so that you can avoid all of the pitfalls in an autoreply generator.

Then, a simple filter (see http://www.postfix.org/SMTPD_PROXY_README.html for how one might implement a before-queue filter to change the destination) for the auto-forwarder.

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.