Scroll to navigation

Mail::Milter::Module::ConnectMatchesHostname(3pm) User Contributed Perl Documentation Mail::Milter::Module::ConnectMatchesHostname(3pm)


Mail::Milter::Module::ConnectMatchesHostname - milter to accept/reject connecting hosts matching regex(es)


    use Mail::Milter::Module::ConnectMatchesHostname;
    my $milter = new Mail::Milter::Module::ConnectMatchesHostname;
    my $milter2 = &ConnectMatchesHostname; # convenience
    $milter2->set_message('Connecting hostname %H looks like a dynamic address');


This milter module rejects any connecting host whose hostname contains one of a group of built-in patterns that match the IP address of the connecting host. This is normally used to detect dynamic pool addresses.

Currently the following patterns embedded in the hostname are considered matching, where is the IPv4 address of the connecting host. In the following cases, the string must be preceded by a non-digit character or otherwise must be at the start of the hostname. (optionally without internal dots, or with - in place of .) (optionally with - in place of .) (optionally without internal dots, or with - in place of .) (optionally with - in place of .)
    0A0B0C0D (hexadecimal, ignoring case)

More specific patterns are anticipated to be added in the future. Because of this, if you use ConnectMatchesHostname, pay attention to this perldoc manual page when updating to a newer version of Mail::Milter.

One final note. ISPs can and do use "dynamic-looking" reverse DNS entries for what they consider to be legitimate server addresses. This is not ideal, and may require embedding this module in a Chain set to "accept_break" with regular expressions; for example:

    my $milter = new Mail::Milter::Chain(



Creates a ConnectMatchesHostname object.


Sets the message used when rejecting connections. This string may contain the substring %H, which will be replaced by the matching hostname, and/or the substring %A, which will be replaced by the matching IP address.

This method returns a reference to the object itself, allowing this method call to be chained.


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

The implementation of this module could be much more efficient.


Todd Vierling, <> <>




Hey! The above document had some coding errors, which are explained below:

You can't have =items (as at line 110) unless the first thing after the =over is an =item
2022-06-14 perl v5.34.0