Last Updated: 27 Sep 2009 GMT +8.
This is a mailfront plugin to provide ability for rejecting/deferring messages based on regular expressions in the senders' remotehost names aka $TCPREMOTEHOST environment variable if found/set or otherwise remoteip aka $TCPREMOTEIP will be used instead.
If you use with tcpserver option -h and -p, then $TCPREMOTEHOST will be set accordingly if valid DNS record is found.
This idea I got it from naokih at iron-horse dot org via google search using badremotehost as search keyword. You can read the qmail patch at http://n.h7a.org/hacks/qmail-badremotehost.patch.
IMPORTANT: This plugin is written for and tested with mailfront 1.12 and should work with later version.
- Line buffer size (defaults to 512)
- If set, the named file is loaded and parsed (see below), and pattern matching is enabled. This is blacklist remotehost in short.
- If set, the named file is loaded and parsed (see below), and pattern matching is enabled. This is whitelist remotehost in short.
- If set, $BADREMOTEHOST matched will reject messages with code 554 instead of 451.
When client starts to transmit data, this plugin will start its regular expressions matching for $GOODREMOTEHOST and $BADREMOTEHOST. If any pattern matches found in $GOODREMOTEHOST, the message won't be deferred/rejected and will bypass $BADREMOTEHOST check if enabled.
If any pattern matches found in $BADREMOTEHOST, the message is rejected if $REMOTEHOST_REJECT is set otherwise it is deferred.
If sender is authenticated or $RELAYCLIENT environment variable is set, then this plugin will be skipped.
Patterns File Format
The patterns file contains a list of standard regular expressions patterns except those lines started with # will be ignored. A control character = appear right after # which is used for customized reject message in $BADREMOTEHOST:
- Comment line, ignored.
- Comment line with a control character =. This is to let you customize reject message. The latest #= line will be used before the pattern matched line. i.e. if the match is at line 4 and there is a #= line before line 4 will be used. It won't use any line after the pattern match. Default response message:
Sorry, your remotehost match our prohibited list. (#5.7.1)
The following patterns list example for $BADREMOTEHOST:
#=We don't accept email from remotehost with bad reverse DNS.
# The below match any $TCPREMOTEHOST = $TCPREMOTEIP due to $TCPREMOTEHOST is not set.
#=We don't accept email from dynamic ip users.
- mailfront version 1.12 or later
- bglibs version 1.104 or later (might work with earlier version)
- Build and install mailfront
- Switch back to this package
- Adjust the contents of the conf-* files
- Build the sources by running "make"
- Install the plugin by running "make install"
Mailfront Plugins Configuration
Place remotehost in mailfront's plugin list. Depending on your setup:
- edit the smtpfront-qmail shell script and place the string remotehost after relayclient
- edit the PLUGINS environment variable and place the string remotehost after relayclient
- place the argument remotehost after the relayclient of the mailfront command
Set up environment as described in Environment Configuration above or plugin-remotehost.html which is included in the package.
This package is copyright © 2009 Giam Teck Choon or CHOON.NET, and may be copied according to the GNU GENERAL PUBLIC LICENSE (GPL) Version 2 or a later version. A copy of this license is included with this package. This package comes with no warranty of any kind.
- 27 Sep 2009 GMT +8 : version 0.02
- Skip regular expressions for goodremotehost and badremotehost if starting line begins with null which is being replaced from newline
- 15 Sep 2009 GMT +8 : version 0.01
- Initial release
- v0.02 md5sum d93c068a8555864e4f39510c47b5ce38
- v0.01 md5sum 7139e1222a336e4bdcf9f8d04b8aeddc