Wednesday, June 22, 2016

Configure postfix to accept all email addresses

There is a solution in http://serverfault.com/questions/514643/postfix-accept-all-email-to-any-user-at-any-domain reporting a solution similar to what I needed.
I'm running raspbian so I think a some things are different, another difference is that I only want to accept addresses to my domain.
The solution was:
  1.  Create the file /etc/postfix/virtual with the content:
    /.*@example.com/ spamuser
  2. Add the following line in file /etc/postfix/main.cf:
    virtual_alias_maps = regexp:/etc/postfix/virtual
  3. Activate the virtual file: postmap /etc/postfix/virtual
Additional notes:
  • The solution in serverfault suggested to use virtual_alias_maps = pcre:/etc/postfix/virtual, with this line I was having the following warning:
    error: warning: pcre:/etc/postfix/virtual is unavailable. unsupported dictionary type: pcre.
    Apparently my install was expecting regexp instead of pcre. To find out the capabilities of your install you can run the command postconf -m
  • To check the status of the service run service postfix status, you will also get a tail of the log, was useful to see configuration errors.