SYNOPSIS

    use Mail::Milter::Module::ConnectRegex;

my $milter = new Mail::Milter::Module::ConnectRegex('^foo$');

my $milter2 = &ConnectRegex(qw{^foo$ ^bar$}); # convenience

$milter2->set_message('Connections from %H disallowed');

DESCRIPTION

This milter module rejects any connecting host whose hostname or \s-1IP\s0 address matches user-supplied regular expressions. It can also function as a whitelisting Chain element; see \*(C`accept_match()\*(C'.

METHODS

new(REGEX[, ...])

Accepts one or more regular expressions, as strings or qr// precompiled regexes. They are tested in sequence, and the first match terminates checking. Note that all \s-1IP\s0 address literals will be enclosed in [square brackets]; so to test an \s-1IP\s0 address rather than a hostname, ensure those brackets exist: ^\[ADDRESS\]$

accept_match(\s-1FLAG\s0)

If \s-1FLAG\s0 is 0 (the default), a matching regex will cause the connection to be rejected. If \s-1FLAG\s0 is 1, a matching regex will cause this module to return \s-1SMFIS_ACCEPT\s0 instead. This allows a \*(C`ConnectRegex\*(C' to be used inside a \*(C`Mail::Milter::Chain\*(C' container (in accept_break(1) mode), to function as a whitelist rather than a blacklist. This method returns a reference to the object itself, allowing this method call to be chained.

set_message(\s-1MESSAGE\s0)

Sets the message used when rejecting connections. This string may contain the substring %H, which will be replaced by the matching hostname or \s-1IP\s0 address. This method returns a reference to the object itself, allowing this method call to be chained.

BUGS

In Sendmail 8.11 and 8.12, a milter rejection at \*(L"connect\*(R" stage does not allow the reply message to be set \*(-- it simply becomes \*(L"not accepting messages\*(R". However, this module still attempts to set the reply code and message in the hope that this will be fixed.

AUTHOR

RELATED TO Mail::Milter::Module::ConnectRegex…

Mail::Milter::Object