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.

I want to configure postfix to only send mail to addresses in a whitelist. I have tried to use smtpd_recipient_restrictions in main.cf like so:

smtpd_recipient_restrictions =
    reject_unauth_destination
    check_recipient_access hash:/path/to/whitelist

The whitelist file is of the format

address@example.com    OK
another@example.com    OK

And then translated into a hash with the postmap command.

Still, the relay is sending mail to non-whitelisted addresses. What am I missing?

Edit: I am sending this mail via the sendmail command, which apparently bypasses the smptd restrictions. Is there a way to deal with this?

Edit 2/The rest of the story: I spent quite a bit of time trying to make sendmail send via SMTP only to discover the command I was using was not sendmail, but postfix's sendmail compatibility interface which mimics functionality but can't be told to use SMTP as far as I could tell.

84104's solution worked perfectly though.

share|improve this question
    
You need to provide the output of postconf -n, so we can see what's real. –  adaptr Aug 23 '12 at 12:22
add comment

1 Answer

up vote 3 down vote accepted

You told postfix to reject some types of mail and accept some other mail. It's possible some messages are not caught be either filter in which case they are permitted. I think you want to tell it to accept (check) only list and reject all else.

smtpd_recipient_restrictions =
    check_recipient_access hash:/path/to/whitelist
    reject

in response to edit:
sendmail(1) uses postdrop(1) not smtpd(8) One way to achieve something like what you're looking for is to manipulate transport(5)'s behavior.

main.cf
    transport_maps = hash:/etc/postfix/transport

transport
    address1@domain.tld :
    address2@domain.tld :
    senderaddress@yourdomain.tld :
    * error: Recipient not whitelisted.

Note: If you don't include the sender's address in the transport map it will be unable to receive bounce messages.

share|improve this answer
    
That makes sense but does not seem to be my principle problem. If I change it to smtpd_recipient_restrictions = reject, it still delivers the mail. –  puffenstuff Aug 21 '12 at 21: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.