How can I forward incoming messages to a specific MTA based on the username portion of the recipient's email address? I would prefer linux-based software, but Windows would work too.

Our organization is transitioning from ISP-hosted POP3 mail to Microsoft Business Productivity Online Services (Exchange Online) and it would be nice to get coexistence working so that some users could be using the new system while other users continue to use the legacy system. As each user is migrated to the new system, their mail could be redirected to the appropriate server independent of other users and of DNS propagation.

Would this system work? Are there other migration schemes more appropriate to the scenario?

Edit 1
Our current ISP is running Postfix and Dovecot. They provide us with the ability to set up email forwarding, but only to a chosen email address. That doesn't really help us because their server will still use the MX record for delivery, which is what I want to bypass.


Postfix offers the ability to forward to different servers based on the recipient username by using transport tables. These tables can be stored as text files or in a database. For example:

legacy_user@example.com smtp:legacymail.example.com:25  
migrated_user@example.com smtp:newmail.example.com:25

Source: http://www.postfix.org/transport.5.html

Per-user transport tables could be used to enable a smooth gradual migration.

  1. Set up a postfix server that forwards mail for all users to the existing ISP
  2. Update DNS so MX record points to postfix server
  3. Wait for DNS to propagate.
  4. Edit transport table so mail for a few users is delivered to new server
  5. Update settings on computers for that batch of users
  6. Repeat steps 4-5 until all users have been migrated
  7. Update DNS so MX record points to new mailserver
  8. Shut down postfix server once traffic ceases

All users who are still using the legacy POP3 system can retain their SMTP settings, as long as that server is doing an MX lookup for users in the same domain. It won't work if their outgoing server is authoritative for the domain. It's possible that users on Exchange Server won't be able to send messages to users on the legacy system because messages will be delivered to the mailbox on Exchange Server.

To make this even more convenient for the sysadmin, Postfix could be integrated with a MySQL database and a web application that allows mail delivery to be toggled for batches of users.

  • This solution worked for me, but Exchange Online cannot be configured to deliver internal same-domain mail to an external SMTP server, so it doesn't help with the migration. – Nic Sep 27 '10 at 15:38

http://www.postfix.org/STANDARD_CONFIGURATION_README.html#some_local has some suggestions.

If you set up an internal Postfix, you can send mail to the appropriate host via transport_maps. Pulling into Exchange can be accomplished via forwarding to a domain on the new Postfix server which then redirects appropriately into Exchange.


What you're looking for is a forwarding mechanism. Chances are your ISP supplied POP system already has the foundation for this kind of thing, though it really depends on what they're using. If they have the ability to set mail rules, or use a .forward (dot-forward), or something similar, you can set those on the mailboxes you want to be on the new system.

Alternately, you can cut everything over the Exchange Online, and use Outlook/Exchange rules to forward mail to the old ISP addresses. This is pretty simple to set up. The big thing is when you move your MX records you need to swap methods; stop forwarding on the POP side and start forwarding on the Exchange side.

  • Our ISP can set up forwarding to an email address, but that doesn't solve the problem. See my edit above. We'll be using the same email addresses on the new system as on the current system. – Nic Sep 24 '10 at 5:22

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.