On Mon, Jul 28, 2008 at 3:08 PM, mouss <[EMAIL PROTECTED]> wrote:
> you're removing the blank line. always be careful with "last".

No, the first pass was just to collect information (i.e. whether the
"**SPAM**" exists on the Subject line). It didn't remove the blank
line in the end of the header.

> why do you split the while loop?

Ok, I revised my version in order to not split the while loop. Same
result as your code, except that the X-Spam header is placed as the
last item of the headers (perhaps cleaner headers, if anyone cares).


my $spamheader = "X-Spam: yes\r\n";
my $check_spam = 1;
my $add_X_spam = 0;
...
while (<$fh>) {
    s/^\./../;
    if ($check_spam) {
      if (s/^Subject:\s*\*\*SPAM\*\*\s+/Subject: /i) {
        $add_X_spam = 1;
      }
      if (/^\s*$/) {
        $check_spam = 0;
      }
    }
    if ($add_X_spam && m/^\s*$/) {
      $_ = $spamheader;
      $add_X_spam = 0;
    }
    $self->{sock}->print($_) or die "$0: write error: $!\n";
}


> BTW. I think the proxy adds \r\n by itself (and removes them when it reads
> the mail). you need to check this though.

If there is no "\r\n" in the end of the spamheader, the following line
in the resultant header is concatenated (or, in above code, the blank
line and thus the separation between the header and the message body,
is lost).

> anyway, count me out now.

Ok. Thanks for advise on this issue; it helped a lot!

Ville

Reply via email to