Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postfix to send all mail to /dev/null except one address (alias)

My postfix server is working on a particular domain name through a relay, so it's like that: Client send to [email protected] -> domain.com production mail server -> internal mail server on subdomain.

All messages for subdomain.domain.com are being forwarded. But the thing is, the application that I'm supporting uses mailing system for some internal stuff and many addresses that are being CC when client is sending e-mail doesn't exist on subdomain mail server, they serve another purpose. When app on subdomain receives e-mail, it parses headers and uses all CC addresses in it's algorithms.

Here comes the problem. When client sends an e-mail, he'll receive as many error responses as there are fake addresses in CC. There is only one real address that is listed in /etc/aliases and it's just piping incoming mails to stdin for some script.

Question. How do I prevent sending error responces to the client and just /dev/null all fake addresses? I need only 1 address, that is listed in aliases.

Thanks in advance.

like image 524
ZackFair Avatar asked Feb 06 '26 16:02

ZackFair


1 Answers

Ok, I figured it out.

This can be achieved through virtual_alias_maps. Add an virtual alias for domain and for address. Redirect domain to /dev/null and address to local alias.

virtual_alias_maps file:

target_addr@subdomain      target@localhost
@subdomain      devnull@localhost

/etc/aliases:

target:  "| /path/to/script"
devnull:  /dev/null
like image 86
ZackFair Avatar answered Feb 09 '26 11:02

ZackFair



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!