I set up Postfix/Dovecot with MySQL on a Linode instance from this tutorial, and I am now trying to forward all email that comes to someaddress@mydomain.com to anotheraddress@anotherdomain.com automatically. For some reason, even after extensive Googling I can't find a guide on how to do that with that particular setup. Does anyone know how?
3 Answers
You have to certify that you have an alias_map
or alias_database
entry in your main.cf
:
alias_database = hash:/etc/aliases
then, inside that file set you alias as desired:
someaddress: anotheraddress@anotherdomain.com
after that run newaliases
and you are good to go.

- 1,135
- 11
- 16
-
Thanks, but this didn't seem to work. Since I have Postfix set up with MySQL, aren't aliases set up through there? Nothing I changed in /etc/aliases seemed to work, even after restarting the Postfix service. – Davis Sorenson Mar 17 '13 at 19:43
-
Can you post your `postconf -n`? Have you tried with `alias_map`? – fboaventura Mar 17 '13 at 23:07
-
Here's my postconf -n: http://pastebin.com/a4VJ2PWR I tried with both `alias_database` and `alias_maps` – Davis Sorenson Mar 18 '13 at 07:34
-
Have you checked the file `mysql-virtual_email2email.cf` and the table associated with it? – fboaventura Mar 18 '13 at 09:28
Maybe a bit late, but here's one really pleasant post on how to set mail forwarding with Postfix/Dovecot through the virtual_alias_map
parameter:
https://geekpeek.net/configure-postfix-mail-forward/
where this article is tightly related to another one by the same author, which can be found here. I recommend checking them out both, because they refer each other too much anyway.
So it seems that the right way to do forwarding it through the virtual alias class and the virtual_alias_map
parameter.
Full documentation on the virtual alias class can be found in the Postfix's docs reference here and here, and an example here.
So here's what Postfix say:
The virtual alias domain class.
Purpose: hosted domains where each recipient address is aliased to a local UNIX system account or to a remote address.
And finally the mail forwarding example:
Mail forwarding domains
Some providers host domains that have no (or only a few) local mailboxes. The main purpose of these domains is to forward mail elsewhere. The following example shows how to set up example.com as a mail forwarding domain:
1 /etc/postfix/main.cf: 2 virtual_alias_domains = example.com ...other hosted domains... 3 virtual_alias_maps = hash:/etc/postfix/virtual 4 5 /etc/postfix/virtual: 6 postmaster@example.com postmaster 7 joe@example.com joe@somewhere 8 jane@example.com jane@somewhere-else 9 # Uncomment entry below to implement a catch-all address 10 # @example.com jim@yet-another-site 11 ...virtual aliases for more domains...
Source: http://www.postfix.org/VIRTUAL_README.html#forwarding

- 273
- 3
- 8

- 141
- 2
-
Is there a way to rewrite the from address? I have this working perfectly, but when I forward emails that came from another domain to be forwarded to an email outside of my domain, the SMTP server I am using to relay does not allow me to forward emails that did not originate from my domain. – Senthil Aug 11 '23 at 15:27
Check this out if you have "virtual mailboxes" already setup and want to use forwarding in addition to them:
https://superuser.com/questions/721917/mixing-virtual-forwards-and-virtual-mailboxes-in-postfix