I had this same desire myself and I made a small edit to fix it to work as I want.
The change will likely be overwritten the next time the postgrey package is updated, but you can hack it by editing /usr/sbin/postgrey
and making the following edits at approximately line 338. You need to add the code shown between the # greylist modifications begin/end
lines:
sub smtpd_access_policy($$)
{
my ($self, $now, $attr) = @_;
my $db = $self->{postgrey}{db};
# This attribute occurs in connections from the policy-test script,
# not in a regular postfix query connection
if(defined $attr->{policy_test_time}) { $now = $attr->{policy_test_time} }
# greylist modifications begin 2014-05-25
if (lc $attr->{recipient} ne 'user1@mydomain.com' &&
lc $attr->{recipient} ne 'user2@mydomain.com') {
$self->mylog_action($attr, 'pass', 'non-targeted greylisting user');
return 'DUNNO';
}
# greylist modifications end 2014-05-25
# whitelists
for my $w (@{$self->{postgrey}{whitelist_clients}}) {
if($attr->{client_name} =~ $w) {
$self->mylog_action($attr, 'pass', 'client whitelist');
[...]
In specific, this disables greylisting for everyone except the named users. This means that user1@mydomain.com and user2@mydomain.com will still have their mail greylisted, but everyone else will have their mail delivered immediately without greylisting.
(I first tried to do this with regexes in the whitelist_recipients
file, but I could never get the “not” syntax to work, so I gave up and just edited the postgrey script instead.)