# Disable greylisting/modify whitelist?

**URL:** <https://discourse.mailinabox.email/t/disable-greylisting-modify-whitelist/137>\
**Category:** uncategorized\
**Created:** [October 21, 2014, 8:58pm UTC](https://discourse.mailinabox.email/t/disable-greylisting-modify-whitelist/137 "2014-10-21T20:58:23Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![essd](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@essd](https://discourse.mailinabox.email/u/essd)\
**Post date:** [May 25, 2015, 5:41pm UTC](https://discourse.mailinabox.email/t/disable-greylisting-modify-whitelist/137/8 "2015-05-25T17:41:18Z")

</div>

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](mailto:user1@mydomain.com) and [user2@mydomain.com](mailto: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.)

---

_[View the full topic](https://discourse.mailinabox.email/t/disable-greylisting-modify-whitelist/137)._
