I brought a new application server online and needed to test the batch email for several weeks. For obvious reasons I didn't want the actual emails to go out and I didn't want to modify the application to fake the addresses. The best solution was to modify the postfix configuration to catch and redirect all outbound messages. My configuration is Ubuntu 10.04.
I scoured the web for a solution and found many incomplete or overly complicated solution. The credit for the best one goes to Mattias Ahnberg on ServerFault.com. Here are his exact instructions:
This worked like a charm and the first time. To disable I just commented virtual_maps line in the main.cf. Thanks Mattias! The original post.
I scoured the web for a solution and found many incomplete or overly complicated solution. The credit for the best one goes to Mattias Ahnberg on ServerFault.com. Here are his exact instructions:
Create/etc/postfix/virtual-regexpwith the following content:
Edit/.+@.+/ email@gmail.com/etc/postfix/main.cfand addregexp:/etc/postfix/virtual-regexpto the virtual_maps configuration. The end result might look like this in main.cf:
Build the mapfile by typing:virtual_maps = hash:/etc/postfix/virtual, regexp:/etc/postfix/virtual-regexp
This also requires a virtual.db to exist. If it doesn't create an empty file called virtual and run : postmap /etc/postfix/virtualpostmap /etc/postfix/virtual-regexp
This worked like a charm and the first time. To disable I just commented virtual_maps line in the main.cf. Thanks Mattias! The original post.