Victor3D Info
Search    Contact

Forward every mail to an external address (Postfix)

Let say you have set up postfix so that your server can send mails. Now you want to be able to receive mails without creating a POP or an IMAP box?

Well… there is a very simple solution for that: you can configure postfix to forward all the incoming mails to your real e-mail address (on GMail, Outlook or any other provider).

A great benefit of this feature is that you can give different mail addresses to different people. For instance, if you hesitate to give your actual address to “”, you could register with That way, you’ll instantly know if they sold your address and you’ll be able to filter the spam.

Configure the DNS

Before configuring postfix, we need to make sure it can be reached from the outside. Therefore the first thing to do is to configure the MX record of you DNS zone, so that it points to your postfix server.

Configure postfix

Append the following to /etc/postfix/

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

Also, be sure to remove from mydestination

Then create the file /etc/postfix/virtual and set the content to:

This file defines a look-up table from local to external addresses. In our case, we only need a “catch-all” address.

Then, run:

sudo postmap /etc/postfix/virtual
sudo service postfix reload


Before trying to forward a mail from internet, you should first try to send a mail from the server itself:

Hi it works !

And check you mail box, including the “spam” folder.

If you have any issue, you can look at the log files:

tail -f /var/log/mail.log
tail -f /var/log/mail.err

Then, if it works with sendmail, you can try sending a mail to from another mail box. Be careful though, if you send the mail from the same address it’s forwarded to, you may not receive the mail.

Black list (optional)

You may now want to prevent spam on common mail addresses, like

Create /etc/postfix/recipient_access with the following content   REJECT

Then run

postmap /etc/postfix/recipient_access

Then edit /etc/postfix/ and add this line:

smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient_access, reject_unauth_destination

Finally, run:

service postfix restart

Starting from now, if someone sends a mail to, he or she will receive an error message.