Forward all incoming email to single address
Last Updated on Wednesday, 21 September 2011 12:41 Tuesday, 20 September 2011 15:02
Forward All incoming Email to single address
Sometimes you don't want to create specific address for specific web site on a server but you want to redirect all incoming messages to a single address. In this tutorial we will explain how to achieve it using Postfix on a Ubuntu Server.
In our example we want to redirect the email info@mydomain.com to myemail@gmail.com
1) Install postfix
During the installation process, the package manager will prompt you for the responses to a few questions. To the first question regarding the type of mail server you want to configure select "No configuration" and continue as in the following image:
Choose : no configuration
Copy the proposed main.cf configuration file
2) Setup catch-all email account
Edit your mapping file by executing the following command
Append the following line in the virtual configuration file .
Save and close the file
3) Post your Mapping
Postmap is utility program that will convert /etc/postfix/virtual to /etc/postfix/virtual.db in Berkley DB format, so that Postfix can access the data faster. We will execute postmap on our newly created virtual mapping. It will rebuild our the virtual alias database
4) Check
Make sure you have the following line in the /etc/postfix/main.cf. If you don't have it feel free to add them.
Line 1 | The virtual_alias_domains setting tells Postfix that mydomain.com is a so-called virtual alias domain. If you omit this setting then Postfix will reject mail (relay access denied) or will not be able to deliver it (mail for mydomain.com loops back to myself). Never list a virtual alias domain name as a mydestination domain! |
Line 2 | The /etc/postfix/virtual file contains the virtual aliases.Mail for all other addresses in mydomain.com is rejected with the error message "User unknown" . |
![]() |
The Postfix main.cf configuration file specifies a very small subset of all the parameters that control the operation of the Postfix mail system. Parameters not explicitly specified are left at their default values. |
5) Restart postfix
or
6) Test your configuration
Postfix logs all failed and successful deliveries to a logfile. The file is usually called /var/log/maillog or /var/log/mail; the exact pathname is defined in the /etc/syslog.conf file.
On Ubuntu
Postfix
sends all log messages to
/var/log/mail.log
. However error and warning messages can sometimes get lost in the normal log output so they are also logged to
/var/log/mail.err
and
/var/log/mail.warn
respectively.
![]() |
When you test Postfix forwarding, don't send the test email from the destination address !!! I am forwarding mail on mydomain.com to my gmail account, but I was testing my setup by sending an email from my gmail account (and expecting it to come back as a forward). THAT WON'T WORK. Test by sending mail from another account. |
To see messages entered into the logs in real time you can use the tail -f command:
If you are having trouble sending or receiving mail from a specific domain you can add the domain to the debug_peer_list parameter.
Tags: install , specific , ubuntu , single , email , postfix , address , incoming , achieve