[vox-tech] procmail question

Tony Cratz cratz at hematite.com
Sat Oct 23 18:28:48 PDT 2010


On 10/23/2010 06:01 PM, Chanoch (Ken) Bloom wrote:
> A quick googling suggests it doesn't know how to do it in-process, but
> you could use the GNU mailutils pipe extension to do such things (in
> conjunction with a program like formail or reformail, or of course a
> spam filter like spamassassin). You can look in /usr/lib/mailutils/ to
> see what extensions are available, and you can write your own as a
> shared library.

	Thanks for the additional info. This support what I thought I
	was seeing. And at one time Procmail/formail was combine
	together as src in a tar file. I'm not sure if this is still
	the case.


>> 	Maildrop was also mention, I only took a quick and dirty look
>> 	at it. Can it also solve the above questions?
> 
> I don't actually use Sieve for my email. I suggested it because it was a
> standard.
> 
> I've used maildrop in the past (rewriting headers, and running spam
> filters with its xfilter command), and my mail filters looked like (for
> example)
> 
>     if (/Mailing-List: list some.mailinglist.org <mailto:NAJSA at yahoogroups.com>; contact/:h ||	\
>         /From:.*foo at bar.com/ || \
>         /From:.*bar at foo.com/ || \
>         /From:.*baz at bar.com/ || \
>         /From:.*@some.domain.org/ || \
>         /Mailing-List: list some-other-mailinglist at yahoogroups.com; / || \
>         /From:.*afinal at email.org/ )
>     {
>           to $MAILBOX/.util.probably-spam
>     }
> 
>     # spam filtering
>     if ($SIZE < 1048576)
>     {
>        xfilter 'spamassassin'
>     }
> 
>     if (/^X-Spam-Status: Yes/)
>     {
>        xfilter 'reformail -I"Status: RO"'
>        to '| $HOME/bin/maildir-deliverread $MAILBOX/.util.probably-spam'
>     }
> 
> 
> I didn't like this (I didn't find it concise enough), and the
> backslashes as line continuations and mandatory braces annoyed me. (I
> was always forgetting them when I made changes, and it would break my
> email for days on end.)

	And once again you supported what I thought I found in my
	short research. I also find maildrop syntax to not be as
	clear as what I would like. I also don't like having to
	escape things when there really is no good reason for it.

	I think there is is room for a new filter program. I have
	thought of a syntax which might be more like a C program.
	My thought was along the line of:

	if ((header_to(name) == "" || header_to(name) != "Tony")
		&& header_to(email) == "cratz at hematite.com" &&
		(header_from(name) != "Tony" && header_from(email) ==
		"cratz at hematite.com"))
	{
		log("Message not sent by Tony");
		next; /* wait for next message */
	} else {
		if (header_get("X-tony-really-sent:") == "secret_key") {
			log("tony sent this message")
			save_message($Tonysent");
			/* save in the tony sent mail box */
		}
	}


	This is not fully flushed out but it gives an idea of kind
	of what I was thinking. There would be a set of functions
	which deals with the envelop, body and attachments. Such as:

Return a structure which contain char *real_name and
	char *email_name

	envelop_header_to()
	envelop_header_from()
	header_to()
	header_from()

	Return a char *value
	header_messageid()
	header_subject()

	header_date_tm() - return a tm struct of the time
	header_date_sec() - returns times in seconds
	
	header_receive() - return array of structures of receive values

	header_list() - return an array headers names (could be used
	to see what headers are contained in messages.

	header_get(matchstring) - return string value of header which
	matches the match string.

	$attach_num - number of attachment
	$attach_size($num)
	$body_size
	$total_message_size

	attachments($num) - return array of info about attachment
	attach_scan($num, string) - matches string in attachment
	(need to think more about this one)

	body_text_html - returns if the body is plain text or html
	body_html(string) - scans the html output for strings
	body_html_code(string) - scan the html_code for string
	body_text(string) - matchings string in body. Newlines are
	converted to what space.

	replace_header("To:", replacement_string)
	mail_message($new_header_altered_message_with_body)
	

	Again this is just the first pass of an idea. I think if the
	syntax was correctly developed it would be clear to understand
	and also be easy to implement Sieve style rules for filtering.

	I'm not ready yet to say it is ready for development. It is
	still early in the thought process. In the mean time, I think
	I will continue to use Procmail until I can find an even better
	program which will do the same things (even though I hate the
	syntax of Procmail).
	


							Tony


More information about the vox-tech mailing list