5

I just want to catch all email sent to * @domain.com AND * @ * .domain.com to a unique email system@domain.Com

@runlevel6 Any idea to implement regexp in virtual like

cat /etc/postfix/virtual 
@example.com system@example.com 
/[@*].example.com$/ system@example.com

I found it:

in main.cf

virtual_alias_maps = regexp:/var/spool/postfix/plesk/virtual-sub

in virtual-sub

/[@.]example\.tld$/ sure@example.tld

thx runlevel6

chahedous
  • 78
  • 1
  • 5

2 Answers2

3

Postfix supports the use of a catchall account using the luser_relay configuration option.

See the postfix page for luser_relay for more information.

When the local(8) delivery agent finds that a message recipient does not exist, the message is normally returned to the sender ("user unknown"). Sometimes it is desirable to forward mail for non-existing recipients to another machine. For this purpose you can specify an alternative destination with the luser_relay configuration parameter.

If it is not a catchall for all domains on the server you can instead user Virtual Aliases. See the postfix page for virtual aliases for more information. Short description and code excerpt from that page are as follows:

With virtual alias domains, each hosted address is aliased to a local UNIX system account or to a remote address. The example below shows how to use this mechanism for the example.com domain.

/etc/postfix/main.cf:

virtual_alias_domains = example.com ...other hosted domains...
virtual_alias_maps = hash:/etc/postfix/virtual

/etc/postfix/virtual:

postmaster@example.com postmaster
info@example.com       joe
sales@example.com      jane
# Uncomment entry below to implement a catch-all address
@example.com           jim
...virtual aliases for more domains...

After making those changes, run postmap /etc/postfix/virtual and postfix reload.

EDIT: I think the regexp that you are looking for is /[@.]example\.com$/ system

You might need to make additional changes in main.cf to support this. See this post for more information.

runlevelsix
  • 2,619
  • 22
  • 20
0

Here's the settings to do a catch-all, but to an external server (I use this server as my smarthost for dev machines).

  • Replace mail.example.com with your server (we use exchange)
  • Replace devteam@example.com with your destination for all emails that are sent to this box.
  • Replace the 192.168.0.0 network with your dev network

postconf -e recipient_canonical_classes=envelope_recipient
postconf -e recipient_canonical_maps=regexp:/etc/postfix/recipient_canonical_map
postconf -e mynetworks=192.168.0.0/24
postconf -e header_checks=regexp:/etc/postfix/header_checks
postconf -e relayhost=mail.example.com

cat /etc/postfix/recipient_canonical_map

/./ devteam@example.com
Jacob Evans
  • 7,886
  • 3
  • 29
  • 57