I have a Linux server which uses Postfix for email. Its on a dynamic ip so I use the "relayhost" parameter to send outgoing mail through an ssh tunnel to another server on a static ip and from there it goes out to the real world. That's been working fine since about 1998 or so.
I'm currently developing some software for a client, and it sends email to various people in that client's organization based on information in a database. For my initial testing, I created fake people who all had email addresses like ptomblin+client1@{mydomain}.com, which worked fine and sent all the email to me. But now I'm working with a live database, and all the email addresses are for real people in the client's organization. I don't particularly want to send email to those people telling them that the system access they requested has been provisioned, so I'd like a way to redirect all email to that client's domain to either my email address or to a file.
If I understand correctly, you want all the mail destinated to example.com be delivered to your mail address or a file, instead of being forwarded to the server specified in relayhost :
step 1: Add example.com to
mydestination
in main.cf so that mail destinated to example.com is delivered locally .step 2: Setup a catchall for example.com and send all email to your mail address or a file. You can for example use postfix pcre to achieve this.
Expanded step 2
Using postfix pcre is only one way to achieve this among many others . According to this tutorial by garisson :
Create a file named aliases-pcre with content :
add the following lines to main.cf (if main.cf is in /etc/postfix):
Restart postfix
Now, all mail destinated to *@example.com should go to mylocaluser mailbox/maildir.
Again, this is just an example. You can use any other method that best fits your needs. I tend to use pcre a lot because it allows regexp that are a bit more complex.
However, the above would not work as you need virtual domain.
Here's a minimal sample configuration :
File
/etc/postfix/aliases-pcre
Ok, Eric got me close to the right path, but not quite there. This is what I did:
In /etc/postfix/main.cf:
In /etc/postfix/virtual_alias
One
postfix reload
later and I was away to the races. (By the way, you don't need to dopostmap
on regular expression files, only hashs)