Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've a Ubuntu 9.04 server installation which is hosting a small number of websites (currently two, and will remain in single figures). The email requirements for the server are very limited - to send outgoing emails and forward all incoming emails to a mailbox on another server - most likely Google.

I've installed postfix and the outgoing mail is working fine. How do I configure Postfix to forward all incoming mail? If I send it to a googlemail address are there any special considerations? Finally how difficult is it to incorporate basic spam filtering into the forwarding mechanism?

share|improve this question
up vote 13 down vote accepted

This is called a "catch all"

Mapping is done using /etc/postfix/virtual file.

vi /etc/postfix/virtual

Append code as follows, replacing domain and emailusername with actual values: emailusername

Save and close the file. Run following command:

postmap /etc/postfix/virtual

Also make sure you have following line in /etc/postfix/ file:

virtual_alias_maps = hash:/etc/postfix/virtual

If you just added above, line reload postfix:

service postfix reload


share|improve this answer
Brilliant stuff. This helped me too. Thanks Matt! – Mike B Dec 1 '09 at 6:16

You need virtual aliases. Something like:

virtual_alias_domains =,
virtual_alias_maps = hash:/etc/postfix/virtual

where /etc/postfix/virtual contains:

run postmap /etc/postfix/virtual to create the database from the map file and postfix reload to re-read the configuration. The virtual table is quite flexible -- you can match specific addresses or whole domains and forward mail to multiple addresses.

Note: Do not list the extra domains in $mydestination! See the docs for more detail.

No special considerations I can think of when sending to GMail addresses. One optional neat trick is to send mail for each domain to a separate address and have GMail automatically label it accordingly. Forward mail for to and to and corresponding filters. See this GMail blog post for more.

I haven't tried but one method to filter spam is to incorporate SpamAssassin. A Google for this turns up quite a few handy-looking guides.

share|improve this answer

Isn't it simpler to use 'always_bcc =' in Denes

share|improve this answer

Note that when using virtual aliases or mail forwarding, Postfix tends to retain the envelope sender from the original message. This causes problems for Gmail and others that use SPF:

Received-SPF: softfail ( domain of transitioning ***@***.com does not
    designate *** as permitted sender);

I haven't found any good solution for this, but here's a hack to sort-of-fix-it:

  1. Create a new file /etc/postfix/sender_canonical:

    /.*/    postmaster
  2. postmap /etc/postfix/sender_canonical

  3. Add some lines to /etc/postfix/

    sender_canonical_classes = envelope_sender
    sender_canonical_maps = regexp:/etc/postfix/sender_canonical
  4. service postfix reload

  5. Send email from an external source and verify that Return-Path contains your postmaster@*** address

Warning: This replaces the envelope sender for all messages passing through your server, which may have unintended side-effects. The message From headers should not be modified by this however, so sender addresses should still display correctly.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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