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

I am trying to blacklist some email addresses but I simply can't get postfix access to work.

Can some point out what I might have don't incorrectly?


smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/check_senders 

to the file in /etc/postfix/

Created /etc/postfix/check_senders I added my address to the file to check that it's functioning This file contains REJECT

Created postfix lookup tables with

#>postmap /etc/postfix/check_senders

Reload and restart postfix

#>postfix reload
#>postfix restart

To test this I created very basic php mail script called test.php

$to = '';
$subject = 'Test postfix access';
$headers = "From: My Name <" . strip_tags('') . ">\r\n";
$headers .= "Reply-To: ". strip_tags($to) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if (mail($to, $subject, 'Test is a test message from the server', $headers)) echo "Sent\n\r";

Ran the file with

#>php test.php

I still receive the email sent by the php script ..... Any ideas?

share|improve this question

you might have two issues here:

  1. check_sender_access checks the envelope sender address. In your php script you only set the "From:"-Header. The envelope sender is probably something completely different (see the "Return-Path" header in the resulting message)

  2. if you run this php script on the same server as postfix, smtpd_recipient_restrictions will not trigger. the php mail()-function submits a mail with the sendmail binary by default, so smtpd is not involved.

-> the problem might not be your postfix config, but your test with php. Try sending an email from an external mail source (like a gmail account ) and see if your blacklist works then

share|improve this answer
I see what you mean. The above s my attempt to achieve this… – garethhallnz Apr 25 '13 at 10:35

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.