I'm having issues rewriting mail. 

In the case that spam has been found, the message rewrites fine.

In the case of real mail, I want the SA headers inserted, but it seems
that if I rewrite_mail on non-spam, the message loses all headers
(except SA headers) and improperly formats the message text (HTML
becomes text, with visible HTML tags).

I must say that I am very impressed with the status of 3.02 and am
hoping this is a config problem on my end, but can't seem to find my own
answer in my searches for it.

Upgrading from 2.60 was relatively painless and it looks to handle the
message parts better.  This code was working on 2.60 (with changes based
on version differences).

The workaround for now is NOT to change the $message_text with
rewrite_mail for non-spam, as doing so will make a messs of the mail.
GTUBE seem fine, and the nonspam (after) seems hosed.  Any help would be
appreciated. (example below)

I have added the "add_header all" config line in the local.cf for each
of the headers I want in each message.

Code snippet follows.

SA 3.02
ActivePerl 5.8 (Build 811)
W2K SP4
Exchange Server 2000 (all available SPs and Hotfixes)

my $spamtest = new Mail::SpamAssassin ({
  userprefs_filename   => 'X:/spam/assassin/prefs/user_prefs',
  local_tests_only     => 1,
  username             => 'someuser'
});

if (is_message_spam($message_text,$spamtest,$mailobj,$statusobj)) {
  #do stuff
} else {
  #do other stuff
}

exit 1;

sub is_message_spam {
  my $message_txt = $_[0];
  my $spamtest = $_[1];
  my @array = split(/\n/,$message_txt);
  my $mail = $spamtest->parse([EMAIL PROTECTED],1);
  my $status = $spamtest->check($mail);
  $mail = $status->get_message();
  $_[2] = $mail;
  $_[3] = $status;
  #$message_txt = $status->rewrite_mail();
  #$_[0] = $message_txt;
  if ($status->is_spam()) {
    $message_txt = $status->rewrite_mail();
    $_[0] = $message_txt;
    return 1;
  } else {
    return 0;
  }
}


NON-SPAM AFTER
--------------
X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on 
        homeexch2.manross.net
X-Spam-Level: 
X-Spam-Status: No, score=0.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_60

        autolearn=no version=3.0.2

This is a multi-part message in MIME format.

--Message-Boundary-19990614
Content-Type: text/plain;
        charset="US-ASCII"
Content-Description: Mail message body
Content-Transfer-Encoding: 7bit

This is a message from Perl with an attachment.
--Message-Boundary-19990614
Content-Type: text/plain;
        type=Unknown;
        name="boot.ini"
Content-Description: boot.ini
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment

[boot
loader]timeout=3D30default=3Dmulti(0)disk(0)rdisk(0)partition(1)\WINNT[o
perating systems]multi(0)disk(0)rdisk(0)partition(1)\WINNT=3D"My System"
--Message-Boundary-19990614--

NONSPAM BEFORE -- HEADERS
-------------------------
thread-index: AcUy9fmcNHhQyjavTVKbUKvxBooZ4g==
Received: from localhost ([x.x.x.x]) by xxxxxxxx.xxxxxxx.xxx with
Microsoft SMTPSVC(5.0.2195.6713); Sun, 27 Mar 2005 10:53:57 -0700
Content-Transfer-Encoding: 7bit
To: <[EMAIL PROTECTED]>
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478
From: "ME" <[EMAIL PROTECTED]>
X-Mailer: Perl+Mail::Sender 0.7.08 by Jan Krynicky
Subject: Perl Mail with Attachment test
MIME-Version: 1.0
Content-Type: Multipart/Mixed;
        boundary="Message-Boundary-19990614"
Return-Path: <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>
X-OriginalArrivalTime: 27 Mar 2005 17:53:57.0443 (UTC)
FILETIME=[F2F4C130:01C532F5]
Date: 27 Mar 2005 10:53:57 -0700
Received: from localhost by homeexch2.manross.net
        with SpamAssassin (version 3.0.2);
        Sun, 27 Mar 2005 10:54:08 -0700
From: "Steven Manross" <[EMAIL PROTECTED]>

To: <[EMAIL PROTECTED]>

Subject: GTUBE

Date: 27 Mar 2005 10:53:57 -0700

Message-Id: <[EMAIL PROTECTED]>

X-Spam-Flag: YES
X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on 
        homeexch2.manross.net
X-Spam-Level: **************************************************
X-Spam-Status: Yes, score=1000.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_99,
        GTUBE autolearn=no version=3.0.2
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_4246F340.7DF40000"

This is a multi-part message in MIME format.

------------=_4246F340.7DF40000
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

Spam detection software, running on the system "homeexch2.manross.net", has
identified this incoming email as possible spam.  The original message
has been attached to this so you can view it (if it isn't spam) or block
similar future email.  If you have any questions, see [EMAIL PROTECTED] for 
details.

auto-spam-learn status: no

Content preview:  GTUBE:
  X<snip>DBQADN1.NSBN3*2IDNEN*G<snip>T-EMAIL*C.34X
  [...] 

Content analysis details:   (1000.7 points, 5.0 required)

 pts rule name              description
---- ---------------------- --------------------------------------------------
-2.9 ALL_TRUSTED            Did not pass through any untrusted hosts
1000 GTUBE                  BODY: Generic Test for Unsolicited Bulk Email
 4.1 BAYES_99               BODY: Bayesian spam probability is 99 to 100%
                            [score: 1.0000]
-0.5 AWL                    AWL: From: address is in the auto white-list



------------=_4246F340.7DF40000
Content-Type: message/rfc822; x-spam-type=original
Content-Description: original message before SpamAssassin
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

thread-index: AcUy9fZHTdFCBEnFTeWo5B3IZUowzA==
Received: from localhost ([10.0.0.1]) by homeexch2.manross.net with Microsoft 
SMTPSVC(5.0.2195.6713); Sun, 27 Mar 2005 10:53:57 -0700
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478
To: <[EMAIL PROTECTED]>
From: "Steven Manross" <[EMAIL PROTECTED]>
X-Mailer: Perl+Mail::Sender 0.7.08 by Jan Krynicky
Subject: GTUBE
Return-Path: <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>
X-OriginalArrivalTime: 27 Mar 2005 17:53:57.0242 (UTC) 
FILETIME=[F2D615A0:01C532F5]
Date: 27 Mar 2005 10:53:57 -0700

GTUBE: <snip>NEN*GTUBE-STAN<snip>EST-EMAIL*C.34X


------------=_4246F340.7DF40000--


thread-index: AcUy9fZHTdFCBEnFTeWo5B3IZUowzA==

Received: from localhost ([10.0.0.1]) by homeexch2.manross.net with Microsoft 
SMTPSVC(5.0.2195.6713); Sun, 27 Mar 2005 10:53:57 -0700

Content-Class: urn:content-classes:message

Importance: normal

Priority: normal

X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478

To: <[EMAIL PROTECTED]>

From: "Steven Manross" <[EMAIL PROTECTED]>

X-Mailer: Perl+Mail::Sender 0.7.08 by Jan Krynicky

Subject: GTUBE

Return-Path: <[EMAIL PROTECTED]>

Message-ID: <[EMAIL PROTECTED]>

X-OriginalArrivalTime: 27 Mar 2005 17:53:57.0242 (UTC) 
FILETIME=[F2D615A0:01C532F5]

Date: 27 Mar 2005 10:53:57 -0700



GTUBE: <snip>EN*GTUBE-STAND<snip>BE-TEST-EMAIL*C.34X




X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on 
        homeexch2.manross.net
X-Spam-Level: 
X-Spam-Status: No, score=0.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_60 
        autolearn=no version=3.0.2

This is a multi-part message in MIME format.

--Message-Boundary-19990614
Content-Type: text/plain;
        charset="US-ASCII"
Content-Description: Mail message body
Content-Transfer-Encoding: 7bit

This is a message from Perl with an attachment.
--Message-Boundary-19990614
Content-Type: text/plain;
        type=Unknown;
        name="boot.ini"
Content-Description: boot.ini
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment

[boot 
loader]timeout=3D30default=3Dmulti(0)disk(0)rdisk(0)partition(1)\WINNT[operating
 systems]multi(0)disk(0)rdisk(0)partition(1)\WINNT=3D"Windows Server 2003, 
Enterpris=e" /fastdetect
--Message-Boundary-19990614--

thread-index: AcUy9fmcNHhQyjavTVKbUKvxBooZ4g==

Received: from localhost ([10.0.0.1]) by homeexch2.manross.net with Microsoft 
SMTPSVC(5.0.2195.6713); Sun, 27 Mar 2005 10:53:57 -0700

Content-Transfer-Encoding: 7bit

To: <[EMAIL PROTECTED]>

Content-Class: urn:content-classes:message

Importance: normal

Priority: normal

X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478

From: "Steven Manross" <[EMAIL PROTECTED]>

X-Mailer: Perl+Mail::Sender 0.7.08 by Jan Krynicky

Subject: Perl Mail with Attachment test

MIME-Version: 1.0

Content-Type: Multipart/Mixed;

        boundary="Message-Boundary-19990614"

Return-Path: <[EMAIL PROTECTED]>

Message-ID: <[EMAIL PROTECTED]>

X-OriginalArrivalTime: 27 Mar 2005 17:53:57.0443 (UTC) 
FILETIME=[F2F4C130:01C532F5]

Date: 27 Mar 2005 10:53:57 -0700



This is a multi-part message in MIME format.



--Message-Boundary-19990614

Content-Type: text/plain;

        charset="US-ASCII"

Content-Description: Mail message body

Content-Transfer-Encoding: 7bit



This is a message from Perl with an attachment.

--Message-Boundary-19990614

Content-Type: text/plain;

        type=Unknown;

        name="boot.ini"

Content-Description: boot.ini

Content-Transfer-Encoding: quoted-printable

Content-Disposition: attachment



[boot loader]
timeout=3D30
default=3Dmulti(0)disk(0)rdisk(0)partition(1)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINNT=3D"Windows Server 2003, Enterpris=
e" /fastdetect


--Message-Boundary-19990614--


Reply via email to