8

I need to configure an SMTP server to accept any email to any address that might happen to reach it on port 25 and deliver it to a local mailbox (i.e. a spam sinkhole)

The default supported MTA on my O/S is Postfix, of which I have no experience. I used to do a lot of Sendmail and Exim, but that was years ago.

Can this be done with Postfix?

3 Answers 3

11

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

1
  • thanks - seems to work fine! I expected that a PCRE map would do it, but the hint I needed was using pcre: for the map file.
    – Alnitak
    Jun 10, 2013 at 15:01
6

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
1

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.

3
  • I need it to catch all domains, not be configured with a list.
    – Alnitak
    Jun 10, 2013 at 13:41
  • Well, that sort of counters the way postfix was designed, and the way mail works (domains need to be configured in postfix, and have an MX record pointing to it), unless you want to create an open relay that doesn't actually forward. Which is possible, AFAIK.
    – NickW
    Jun 10, 2013 at 13:42
  • 1
    Yes, an open relay that doesn't relay (and then redirects to a local mailbox) would achieve what I need.
    – Alnitak
    Jun 10, 2013 at 13:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .