You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Mark Chaney <ma...@lists.macscr.com> on 2014/01/07 14:29:12 UTC

add_header format

I am using spamassassin standalone and I am trying to figure out how to 
duplicate this format that I would normally get from my servers that 
user amavis or mailscanner. How can I get a format like so? Ive read the 
manual, but havent really figured it out. I also have no use for the 
spam-checker-version

X-Spam-Flag: YES
X-Spam-Score: 14.176
X-Spam-Level: **************
X-Spam-Status: Yes, score=14.176 tagged_above=-10 required=5
	tests=[AWL=-1.500, BAYES_95=4.5, DATE_IN_PAST_06_12=1.543,
	HTML_MESSAGE=0.001, KAM_SOLAR=3.5, MIME_HTML_MOSTLY=0.428,
	MPART_ALT_DIFF=0.79, NUMERIC_HTTP_ADDR=1.242, RDNS_NONE=0.793,
	SO_RDNS_UNKNOWN=0.35, SPF_HELO_SOFTFAIL=0.732, SPF_SOFTFAIL=0.665,
	T_REMOTE_IMAGE=0.01, URI_HEX=1.122] autolearn=no

Right now I just get:

X-Spam-Status: No, score=3.3 required=5.0 tests=EMPTY_MESSAGE,SPF_FAIL,
	T_RP_MATCHES_RCVD autolearn=no
X-Spam-Level: ***
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on 
mx4.example.com

Re: add_header format

Posted by Mark Chaney <ma...@lists.macscr.com>.
Thanks everyone for the ideas, two things though:

1) I am not doing any type of custom filter on the relay server that SA 
is running on, I was just more hoping for that particular format as I 
think it has the best information without a mess. I honestly dont know 
the first thing about creating custom filters for manipulating the SA 
add_header output.

2) I am filtering it at the destination server though by moving emails 
with X-Spam-Flag: YES to their Junk imap folder.


On 2014-01-07 09:38, Benny Pedersen wrote:
> Bowie Bailey skrev den 2014-01-07 15:55:
>> If you want this report on all messages, you can add the following
>> line to your local.cf or user_prefs file:
>> 
>> add_header all Report _REPORT_
> 
> or better maybe:
> 
> add_header spam SpamReport _REPORT_
> add_header ham HamReport _REPORT_
> 
> this is more easy to grep in scripts or procmail then

Re: add_header format

Posted by Benny Pedersen <me...@junc.eu>.
Bowie Bailey skrev den 2014-01-07 15:55:
> If you want this report on all messages, you can add the following
> line to your local.cf or user_prefs file:
> 
> add_header all Report _REPORT_

or better maybe:

add_header spam SpamReport _REPORT_
add_header ham HamReport _REPORT_

this is more easy to grep in scripts or procmail then



Re: add_header format

Posted by Bowie Bailey <Bo...@BUC.com>.
On 1/7/2014 8:29 AM, Mark Chaney wrote:
> I am using spamassassin standalone and I am trying to figure out how to
> duplicate this format that I would normally get from my servers that
> user amavis or mailscanner. How can I get a format like so? Ive read the
> manual, but havent really figured it out. I also have no use for the
> spam-checker-version
>
> X-Spam-Flag: YES
> X-Spam-Score: 14.176
> X-Spam-Level: **************
> X-Spam-Status: Yes, score=14.176 tagged_above=-10 required=5
> 	tests=[AWL=-1.500, BAYES_95=4.5, DATE_IN_PAST_06_12=1.543,
> 	HTML_MESSAGE=0.001, KAM_SOLAR=3.5, MIME_HTML_MOSTLY=0.428,
> 	MPART_ALT_DIFF=0.79, NUMERIC_HTTP_ADDR=1.242, RDNS_NONE=0.793,
> 	SO_RDNS_UNKNOWN=0.35, SPF_HELO_SOFTFAIL=0.732, SPF_SOFTFAIL=0.665,
> 	T_REMOTE_IMAGE=0.01, URI_HEX=1.122] autolearn=no
>
> Right now I just get:
>
> X-Spam-Status: No, score=3.3 required=5.0 tests=EMPTY_MESSAGE,SPF_FAIL,
> 	T_RP_MATCHES_RCVD autolearn=no
> X-Spam-Level: ***
> X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
> mx4.example.com

That format is generated by Amavis.  SA will generate a more verbose 
header in messages marked as spam.

For example:

X-Spam-Status: Yes, score=7.7 required=4.0 tests=BAYES_99,DCC_CHECK,
     DIGEST_MULTIPLE,RAZOR2_CHECK,RP_MATCHES_RCVD,URIBL_DBL_SPAM
     autolearn=disabled version=3.3.2
X-Spam-Report:
     *  4.0 BAYES_99 BODY: Bayes spam probability is 99 to 100%
     *      [score: 1.0000]
     * -0.3 RP_MATCHES_RCVD Envelope sender domain matches handover 
relay domain
     *  1.7 URIBL_DBL_SPAM Contains an URL listed in the DBL blocklist
     *      [URIs: ********.com]
     *  1.1 DCC_CHECK Detected as bulk mail by DCC (dcc-servers.net)
     *  0.9 RAZOR2_CHECK Listed in Razor2 (http://razor.sf.net/)
     *  0.3 DIGEST_MULTIPLE Message hits more than one network digest check

If you want this report on all messages, you can add the following line 
to your local.cf or user_prefs file:

add_header all Report _REPORT_

-- 
Bowie

Re: add_header format

Posted by Martin Gregorie <ma...@gregorie.org>.
On Tue, 2014-01-07 at 07:29 -0600, Mark Chaney wrote:
> I am using spamassassin standalone and I am trying to figure out how to 
> duplicate this format that I would normally get from my servers that 
> user amavis or mailscanner. How can I get a format like so? Ive read the 
> manual, but havent really figured it out. I also have no use for the 
> spam-checker-version
> 
> X-Spam-Flag: YES
> X-Spam-Score: 14.176
> X-Spam-Level: **************
> X-Spam-Status: Yes, score=14.176 tagged_above=-10 required=5
> 	tests=[AWL=-1.500, BAYES_95=4.5, DATE_IN_PAST_06_12=1.543,
> 	HTML_MESSAGE=0.001, KAM_SOLAR=3.5, MIME_HTML_MOSTLY=0.428,
> 	MPART_ALT_DIFF=0.79, NUMERIC_HTTP_ADDR=1.242, RDNS_NONE=0.793,
> 	SO_RDNS_UNKNOWN=0.35, SPF_HELO_SOFTFAIL=0.732, SPF_SOFTFAIL=0.665,
> 	T_REMOTE_IMAGE=0.01, URI_HEX=1.122] autolearn=no
> 
> Right now I just get:
> 
> X-Spam-Status: No, score=3.3 required=5.0 tests=EMPTY_MESSAGE,SPF_FAIL,
> 	T_RP_MATCHES_RCVD autolearn=no
> X-Spam-Level: ***
> X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on 
> mx4.example.com
> 
The X-Spam-Status, X-Spam-Level and X-Spam_Checker-Version headers are
output by SA. The X-Spam-Flag and X-Spam-Score headers came from amavis
or mailscanner and simply repackage the first two information fields in
X-Spam-Status.

I assume you're writing your own filter program. If so, it can use the
values in X-Spam-Status to quarantine spam rather than passing it on. My
own filter does this. However, if something further downstream needs the
X-Spam-Flag and/or X-Spam-Score headers, just create them using the data
in X-Spam-Status and add them to the message.

I wrote my filter in C, but if all you want to do is add those two
headers, then you can do that by writing a filter script. That should
take about 10 minutes using awk or a bit longer if you prefer Perl.

Martin






Re: add_header format

Posted by Mark Chaney <ma...@lists.macscr.com>.
I am not using amavis and do not want to use it.

On 2014-01-10 04:20, Benny Pedersen wrote:
> Mark Chaney skrev den 2014-01-10 06:55:
> 
>> I know that information is already included in the X-Spam-Status, but
>> I really need them to be separate available on with their own line as
>> well. I guess its not possible to specify multiple add_header entries?
> 
> http://blog.dmitryleskov.com/small-hacks/forcing-spamassassin-to-add-the-x-spam-status-header-to-ham-for-debugging/
> http://spamassassin.apache.org/full/3.1.x/doc/Mail_SpamAssassin_Conf.html
> 
> you use amavisd-new ?, not all add_header works there, so test first
> it works natively in spamassassin, when it does continue with
> amavisd-new, reason for it diffrents is that amavisd is multiple msgs
> optimized so it just does not need to make add headers pr msg, scan
> once and do still pr recipient add header, spamd/spamc cant do this
> yet, since spamd always see pr recipient anyway
> 
> i just google it :)

Re: add_header format

Posted by Benny Pedersen <me...@junc.eu>.
Mark Chaney skrev den 2014-01-10 06:55:

> I know that information is already included in the X-Spam-Status, but
> I really need them to be separate available on with their own line as
> well. I guess its not possible to specify multiple add_header entries?

http://blog.dmitryleskov.com/small-hacks/forcing-spamassassin-to-add-the-x-spam-status-header-to-ham-for-debugging/
http://spamassassin.apache.org/full/3.1.x/doc/Mail_SpamAssassin_Conf.html

you use amavisd-new ?, not all add_header works there, so test first it 
works natively in spamassassin, when it does continue with amavisd-new, 
reason for it diffrents is that amavisd is multiple msgs optimized so it 
just does not need to make add headers pr msg, scan once and do still pr 
recipient add header, spamd/spamc cant do this yet, since spamd always 
see pr recipient anyway

i just google it :)



Re: add_header format

Posted by Mark Chaney <ma...@lists.macscr.com>.
Thanks, that helps a bit:

X-Spam-Status: No, score=4.6 required=5.0 tests=[AWL=-0.040,
	RP_MATCHES_RCVD=-0.001, SO_FROM_HJPC=0.65, SO_HELO_LDOM=0.65,
	SO_LOCAL_FROM=-0.1, SO_NOT_FROM_RP=2.5, SPF_FAIL=0.919] autolearn=no
X-Spam-Level: ****

But I am still missing these two lines:

X-Spam-Flag: YES
X-Spam-Score: 14.176

I know that information is already included in the X-Spam-Status, but I 
really need them to be separate available on with their own line as 
well. I guess its not possible to specify multiple add_header entries?


On 2014-01-09 18:21, Karsten Bräckelmann wrote:
> On Tue, 2014-01-07 at 07:29 -0600, Mark Chaney wrote:
>> I am using spamassassin standalone and I am trying to figure out how 
>> to
>> duplicate this format that I would normally get from my servers that
>> user amavis or mailscanner. How can I get a format like so? Ive read 
>> the
>> manual, but havent really figured it out. I also have no use for the
>> spam-checker-version
> 
> The X-Spam-Checker-Version header is added by SA unconditionally, since
> it provides vital data for support. That header can not be removed.
> 
>> X-Spam-Flag: YES
>> X-Spam-Score: 14.176
>> X-Spam-Level: **************
>> X-Spam-Status: Yes, score=14.176 tagged_above=-10 required=5
>> 	tests=[AWL=-1.500, BAYES_95=4.5, DATE_IN_PAST_06_12=1.543,
>> 	HTML_MESSAGE=0.001, KAM_SOLAR=3.5, MIME_HTML_MOSTLY=0.428,
>> 	MPART_ALT_DIFF=0.79, NUMERIC_HTTP_ADDR=1.242, RDNS_NONE=0.793,
>> 	SO_RDNS_UNKNOWN=0.35, SPF_HELO_SOFTFAIL=0.732, SPF_SOFTFAIL=0.665,
>> 	T_REMOTE_IMAGE=0.01, URI_HEX=1.122] autolearn=no
> 
> The following SA configuration mimics the Amavis Status header. Mind 
> the
> line wrap and extra indentation added for readability.
> 
>   add_header all Status  _YESNO_, score=_SCORE()_ required=_REQD_
>                          tests=[_TESTSSCORES(, )_] 
> autolearn=_AUTOLEARN_
> 
> The tagged_above value is an Amavis thing, not applicable for SA. As I
> understand, the important bit you're after is the _TESTSSCORES(, )_
> Template Tag anyway -- note the custom separator. See
> 
>   
> http://spamassassin.apache.org/doc/Mail_SpamAssassin_Conf.html#template_tags
> 
> for more details about the Template Tags used. Also see the M::SA::Conf
> documentation for the add_header option.


Re: add_header format

Posted by Karsten Bräckelmann <gu...@rudersport.de>.
On Tue, 2014-01-07 at 07:29 -0600, Mark Chaney wrote:
> I am using spamassassin standalone and I am trying to figure out how to 
> duplicate this format that I would normally get from my servers that 
> user amavis or mailscanner. How can I get a format like so? Ive read the 
> manual, but havent really figured it out. I also have no use for the 
> spam-checker-version

The X-Spam-Checker-Version header is added by SA unconditionally, since
it provides vital data for support. That header can not be removed.

> X-Spam-Flag: YES
> X-Spam-Score: 14.176
> X-Spam-Level: **************
> X-Spam-Status: Yes, score=14.176 tagged_above=-10 required=5
> 	tests=[AWL=-1.500, BAYES_95=4.5, DATE_IN_PAST_06_12=1.543,
> 	HTML_MESSAGE=0.001, KAM_SOLAR=3.5, MIME_HTML_MOSTLY=0.428,
> 	MPART_ALT_DIFF=0.79, NUMERIC_HTTP_ADDR=1.242, RDNS_NONE=0.793,
> 	SO_RDNS_UNKNOWN=0.35, SPF_HELO_SOFTFAIL=0.732, SPF_SOFTFAIL=0.665,
> 	T_REMOTE_IMAGE=0.01, URI_HEX=1.122] autolearn=no

The following SA configuration mimics the Amavis Status header. Mind the
line wrap and extra indentation added for readability.

  add_header all Status  _YESNO_, score=_SCORE()_ required=_REQD_
                         tests=[_TESTSSCORES(, )_] autolearn=_AUTOLEARN_

The tagged_above value is an Amavis thing, not applicable for SA. As I
understand, the important bit you're after is the _TESTSSCORES(, )_
Template Tag anyway -- note the custom separator. See

  http://spamassassin.apache.org/doc/Mail_SpamAssassin_Conf.html#template_tags

for more details about the Template Tags used. Also see the M::SA::Conf
documentation for the add_header option.


-- 
char *t="\10pse\0r\0dtu\0.@ghno\x4e\xc8\x79\xf4\xab\x51\x8a\x10\xf4\xf4\xc4";
main(){ char h,m=h=*t++,*x=t+2*h,c,i,l=*x,s=0; for (i=0;i<l;i++){ i%8? c<<=1:
(c=*++x); c&128 && (s+=h); if (!(h>>=1)||!t[s+h]){ putchar(t[s]);h=m;s=0; }}}