From cc73e91bf8955171ac287e316a4cbb984d936d32 Mon Sep 17 00:00:00 2001 From: ps Date: Tue, 28 Jun 2011 21:46:35 +0000 Subject: [PATCH] add the add_status_header_if_dns_listed option --- src/Configfile.tmpl | 6 ++++++ src/Proxy.cpp | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Configfile.tmpl b/src/Configfile.tmpl index 1d54719..0d1d8c7 100644 --- a/src/Configfile.tmpl +++ b/src/Configfile.tmpl @@ -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 diff --git a/src/Proxy.cpp b/src/Proxy.cpp index 13b6992..aeb4e6a 100644 --- a/src/Proxy.cpp +++ b/src/Proxy.cpp @@ -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);