In Exim this would be handled by a wildcard alias, and a pipe transport. Look for the equivalent for Postfix. Aliases can be configured to specify a command to handle the message.
If you have other domains you want to handle differently, setup virtual domain aliases and put the wildcard in the aliases file for the domain.
It looks like Postfix has a pipe daemon to handle deliveries to a command.
EDIT: Exim solution using split configuration. This requires installing the exim4-daemon-light
package. I would suggest you also install the exim4-doc-html
package to provide the documentation at http://localhost/doc/exim4-doc-html/html/spec_html/
.
Add a file in /etc/exim4/conf.d/router
named 380_local-config_program_router
. Check the options of generic routers i (chapter 15 and 16 in the specification). Change the script name and domain as required.
# This router runs /usr/bin/your-script for all users in your.domain.
program_router:
driver = accept
require_files = /usr/bin/your-script
transport = program_transport
domains = your.domain
Add a file in /etc/exim4/conf.d/transport
named 380_local-config_program_transport
. Check the options for pipe transport (chapters 24 and 29 in the specification). You will need to set the options which don't have a value specified. Also set the correct command which can have options if required.
program_transport:
driver = pipe
command = /usr/bin/your-script
current_directory =
home_directory =
user =
group =
I modified the configuration from this post.
Edit2: It looks like you can do it with Postfix as well. A solution using a wildcard address for a virtual domain and a maildrop type indirect delivery should do it.