Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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+*@gmail.com (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
add comment

1 Answer 1

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 main.cf:

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+.*@gmail.com$/  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 http://www.postfix.org/access.5.html.

For information on the regexp lookups supported by postfix, read here http://www.postfix.org/regexp_table.5.html.

And finally, for more information on the smtpd_recipient_restrictions option, read here http://www.postfix.org/postconf.5.html#smtpd_recipient_restrictions.

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
add comment

Your Answer

 
discard

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.