Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Essentially I only want to allow my CentOS box to send mail to specific addresses (with patterns if possible).

Such addresses would be:

  • user@domain.tld
  • user+* (in this instance I am using Gmail account with Plus Trick to serve as a recipient for a large number of fake users, however it's important that the server is not able to send to OTHER gmail users.

I've switched from Sendmail to Postfix on some friendly advice that Postfix is simply more configurable, but now I've made that switched and started digging, I'm getting just as frustrated as when I has sendmail!

I've been scouring postfix documents but there seems to be a void between where my understanding ends, and the documentation begins, and I'm failing to really gain much purchase on how to get started.

Thanks for any advice!

share|improve this question

I have to wonder... Why do you want this? It sounds like you're probably expecting your mail server to do some sort of security screening that it ought not be doing. But... to answer your question...

You can probably accomplish this with the "smtpd_recipient_restrictions" option in

smtpd_recipient_restrictions = check_recipient_access regexp:/etc/postfix/recipient_filter,
    permit_mynetworks, reject_unauth_destination

Then create a file called /etc/postfix/recipient_filter, and add your patterns:

/^user@domain.tld$/    DUNNO
/^user+.*$/  DUNNO
/.*/                   REJECT

The reason for DUNNO instead of OK, is so that the permit_mynetworks and reject_unauth_destination checks will still happen. With OK, presumably anyone trying to send mail (even spammers, or a virus-infested PC on your network) would be able to send email to the allowed addresses.

This configuration is untested, so may require some additional tweaking. For information on the result codes used in the /etc/postfix/recipient_filter file see read the access(5) man page here

For information on the regexp lookups supported by postfix, read here

And finally, for more information on the smtpd_recipient_restrictions option, read here

share|improve this answer
Thanks for this tip, I'll give it a whirl! :D My main reason for using this is that it's a staging server where we often pull production data to for testing deployments. As a result, we have had data send out to end-users from testing which is obviously something that should be avoided. While I understand the problem should be solved elsewhere primarily, I'm just trying to tighten it up everywhere I can. – DanH Jun 17 '11 at 2:26
I was messing with smtp_header_checks for ages yesterday as well, until I figured out that lots of the actions for header_checks are not supported in the smtp variant facepalm – DanH Jun 17 '11 at 2:28
Your requirement makes more sense now; I can see a legitimate case for only allowing specific mails from a test server. Maybe that's something I need at my work! :) Anyway, I hope my suggestion works for you. – Flimzy Jun 17 '11 at 2:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.