Forwarding Email

Mail can be forwarded in several different ways.

Forwarding an individual's mail elsewhere

If you would like to forward email for a user elsewhere, simply create a file called forward inside that user's mailbox directory, with a comma-separated list of addresses to which email should be forwarded.

For example, to forward all email from alice@example.com to bob@example.net, create the file /srv/example.com/mailboxes/alice/forward containing 'bob@example.net'.

More complex forwarding can also be achieved as this forward file can be interpreted as an Exim filter

Forwarding all mail for a single domain elsewhere

If you would like all mail for one domain to be delivered to a single mailbox, create a file called default_forward inside the config directory for that domain. This is a catch-all feature, and will only work for addresses not explicitly configured already, i.e. for addresses without a directory under mailboxes.

For example, to deliver all mail for example.com to jim@example.net, create the file /srv/example.com/config/default_forward containing 'jim@example.net'.

Once again, more complex forwarding can be done using Exim filter magic in this file.

NB This is a catch-all rule and will work on email addresses not previously configured under the mailboxes directory.

NB 2 The address you are forwarding to must exist, or email will bounce. So if it is a local address, do not forget to create the appropriate directory under mailboxes/.

Rewriting all addresses in one domain to another

There are two ways this can be done. If one domain is simply an alias for another, and instead of having a directory in /srv, it is merely a symbolic link pointing to another domain defined in /srv, then all mail will be rewritten for that domain.

For example, /srv contains

drwxr-xr-x  6 admin admin 4096 2008-04-04 17:31 example.com
lrwxrwxrwx  1 admin admin   16 2008-04-01 12:17 www.example.com -> /srv/example.com

i.e. www.example.com is a symbolic link pointing at example.com, then mail addressed to alice@www.example.com will get delivered to alice@example.com.

Rewriting all addresses in one domain to another using the default_forward file

The second way of doing this is using an Exim filter combined with the default_forward file.

For example, to achieve the same effect as the last example, /srv/www.example.com should be a directory, and the filter file in /srv/www.example.com/config/default_forward should contain the following:

# Exim filter <-- Required to ensure Exim recognises this file as a filter
deliver $local_part@example.com

Once again, an email addressed to alice@www.example.com will get delivered to alice@example.com.

NB The directory /srv/www.example.com/mailboxes must exist for this to work. This is a bug which needs fixing.

Further Information