add the add_status_header_if_dns_listed option

This commit is contained in:
ps 2011-06-28 21:46:35 +00:00
parent a9ce0d5e33
commit cc73e91bf8
2 changed files with 15 additions and 1 deletions

View File

@ -107,6 +107,12 @@ list,dns_whitelist_domains,""
* as listed, just define dns_whitelist_percentage as 50 (50%).
int,dns_whitelist_percentage,100
* if this is enabled, email will get tagged with a header "X-Hermes-Status: {white,black}listed"
* that way, your bayesian filter can learn from this automatically
* NOTE: if this is enabled, it will accept blacklisted emails and it will be up to you to filter
* them out, for example through procmail
bool,add_status_header_if_dns_listed,false
* time to delay the initial SMTP banner
int,banner_delay_time,5

View File

@ -52,11 +52,13 @@ void Proxy::run(string &peer_address)
bool authenticated=false; //we start with a non-authenticated connection
bool esmtp=false;
string strtemp;
string hermes_status="unknown";
//check whitelist
if(!cfg.getDnsWhitelistDomains().empty()&&Utils::listed_on_dns_lists(cfg.getDnsWhitelistDomains(),cfg.getDnsWhitelistPercentage(),peer_address))
{
authenticated=true;
hermes_status="whitelisted";
if(true==cfg.getWhitelistedDisablesEverything())
throttled=false;
}
@ -159,7 +161,11 @@ void Proxy::run(string &peer_address)
//check rbl
else if(!cfg.getDnsBlacklistDomains().empty()&&!authenticated&&Utils::listed_on_dns_lists(cfg.getDnsBlacklistDomains(),cfg.getDnsBlacklistPercentage(),peer_address))
{
code=cfg.getReturnTempErrorOnReject()?"421":"550";
hermes_status="blacklisted";
if(cfg.getAddStatusHeaderIfDnsListed())
code="250";
else
code=cfg.getReturnTempErrorOnReject()?"421":"550";
mechanism="dnsbl";
message=code+" You are listed on some DNS blacklists. Get delisted before trying to send us email.";
LINF("checking " + mechanism);
@ -246,6 +252,8 @@ void Proxy::run(string &peer_address)
inside.writeLine(" by "+Utils::gethostname()+" with "+(esmtp?"ESTMP":"SMTP")+" via TCP; "+Utils::rfc2821_date());
inside.writeLine("X-Anti-Spam-Proxy: Proxied by Hermes [www.hermes-project.com]");
}
if(cfg.getAddStatusHeaderIfDnsListed())
inside.writeLine("X-Hermes-Status: "+hermes_status);
do
{
bytes_read=outside.readBytes(buffer,sizeof(buffer)-1);