Postfix - accept all email to any user at any domain
You can do this using virtual mailboxes. Instead of the usual lookup maps, you'd have a PCRE table that looks like this:
/.*/ spamuser
to return the username spamuser
regardless of what email address is the recipient.
In your postfix.conf you'd have the line
virtual_alias_maps = pcre:/etc/postfix/virtual
There's more information about both virtual alias maps and PCRE tables at postfix.org
Here is how I done it
create user webmail
adduser webmail
I had to install the postfix-pcre package. Code:
sudo apt-get install postfix-pcre
I created a file called /etc/postfix/virtual as follows:-
Code:
/.*/ webmail
edited /etc/postfix/main.cf
to add this line:
virtual_alias_maps = pcre:/etc/postfix/virtual
For the absolute newbies (like me), if the configuration is correct, the query command: Code:
postmap -q test@a pcre:/etc/postfix/virtual
would return the email id specified in virtual file (/etc/postfix/virtual). In this case. Code:
webmail
To test the working, use the mail command from the terminal. Code:
mail [email protected]
enter the subject, mail body and press Ctrl+D (to exit the compose window).
To view the message use the following command. (webmail is the mail id configured in virtual file. Substitute with your name.) Code:
mail webmail
PS:To check the mail log use the following command. Code:
tail -f /var/log/mail.log
If you want to make postfix into an open proxy that will accept mail for any domain, you may want to look into this piece of code: http://www.postfix.org/smtp-sink.1.html
It's basically a load tester (accept then discard), but you can also configure it to accept then store.