Take the 2-minute tour ×

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

myemail@domain.com 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 = 'myemail@domain.com';
$subject = 'Test postfix access';
$headers = "From: My Name <" . strip_tags('myemail@domain.com') . ">\r\n";
$headers .= "Reply-To: ". strip_tags($to) . "\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

1 Answer 1

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 stackoverflow.com/questions/16160884/… –  garethhallnz Apr 25 '13 at 10:35

Your Answer


