[Mimedefang] HDRS question

David F. Skoll dfs at roaringpenguin.com
Wed Apr 7 20:57:12 EDT 2004


On Wed, 7 Apr 2004, J.D. Bronson wrote:

> open(HDRS, "<HEADERS");

You should check for failure of open, I suppose...

>          $count = 0;
>          while(<HDRS>) {
>          $count++ if /^X-Disclaimer-Added:/;
>          }
>          close(HDRS);

Looks cool so far...

>          for ($i=1; $i <= $count; $i++) {
>          return 0;
>          }

Ummm... That actually looks like it will work, but it's right up there
for the most roundabout way of doing things! :-)

>      if ($RelayAddr =~ "^192\.168\.10") {
>      append_text_boilerplate($entity, $boilerplate, 0);
>      action_add_header('X-Disclaimer-Added', "YES");
> }

I believe you want:

	$disclaimer_added = 0;
	if (open(HDRS, "<HEADERS")) {
		while(<HDRS>) {
			if (/^X-Disclaimer-Added/) {
				$disclaimer_added = 1;
				last;
			}
		}
		close(HDRS);
	}
	if (!$disclaimer_added && $RelayAddr =~ /^192\.168\.10\./) {
		append_text_boilerplate($entity, $boilerplate, 0);
		action_add_header('X-Disclaimer-Added', "YES");
	}


However, this is unlikely to solve your problem.  If someone replies to
or forwards the message, the MUA is extremely unlikely to preserve
the X-Disclaimer-Added header, and therefore the disclaimer will be
added again.

There are two reasonably reliable ways to avoid disclaimer-duplication:

1) Search the *message body* for the disclaimer text, showing tolerance for
junk like ">" at the beginning of lines.

2) Don't add disclaimers.  (2) is my preferred approach. :-)

Regards,

David.



More information about the MIMEDefang mailing list