[milters] Archive

Lists Index Date Thread Search

Article: 808
From: Anthony Howe
Date: 2006-02-04 07:21:08 -0500
Subject: Re: How can I embed spamlevel in subject line

Removal...........: milters-request@milter.info?subject=remove
More information..: http://www.milter.info/#Support
--------------------------------------------------------

Don Reiher wrote:
> I am presently using a custom subjectTag to flag spam and
> it works very well.  Groupwise cannot use the score and
> threshold tag to delete spam above a certain level. The
> rules are not that sophisticated.  I cannot search on
> X-Spam-Level in the header. . . it is not available to
> the rules in Groupwise 6.5.

What about the X-Spam-Flag: header, which is a simple boolean YES or NO.

> I studied the code for a while. . . but I am not that good
> with arrays.   I cannot seem to figure out how to do this.
> Can someone help me with some snippets?  I just need someone
> to get me started. . . I can finish it myself.

The X-Spam-Level: header is simply the integer representation of the 
spam score rounded down. Its not clipped for higher values but that 
could easily be done if desired.

Change:

	iscore = (int) score;
	for (i = 0; i < iscore; i++)
		data->line[i] = DEFAULT_SPAM_LEVEL_CHARACTER;
	data->line[i] = '\0';

to

	iscore = (int) score;
	/* Clip to a max. number of level characters. */
	if (20 < iscore)
		iscore = 20;
	for (i = 0; i < iscore; i++)
		data->line[i] = DEFAULT_SPAM_LEVEL_CHARACTER;
	data->line[i] = '\0';

> There needs to be a maximum amount of x's like 20 or so.
> Too many x's and I won't be able to read the subject.

data->line is a general purpose buffer that gets reused in several 
places. In order to place the level characters into the subject tag 
instead you would have to use a different buffer to hold the stars so 
that they could be formatted into the modified subject header.

So we have to save them in a buffer we don't need any more. After this 
block of code:

	iscore = (int) score;
	/* Clip to a max. number of level characters. */
	if (20 < iscore)
		iscore = 20;
	for (i = 0; i < iscore; i++)
		data->line[i] = DEFAULT_SPAM_LEVEL_CHARACTER;
	data->line[i] = '\0';

Insert

	TextCopy(data->helo, sizeof (data->helo), data->line);

(data->helo is no longer required by this point and can be reused for 
something else; generally not a good idea to retask buffers, but it is 
after all a quick hack.)

Then where the updated subject is formatted, replace subjectTag with 
data->helo (of course this will break the -s option ie. make it a noop). 
Alternatively modify the format strings for the subject to include the 
level characters kept in data->helo

-- 
Anthony C Howe                                 +33 6 11 89 73 78
http://www.snert.com/       ICQ:
7116561         AIM: Sir Wumpus

Sendmail Anti-Spam Solutions           http://www.snertsoft.com/
                                             We Serve Your Server

Lists Index Date Thread Search