- Better handling of automated messages and post bounces for CS Mail.

This commit is contained in:
JT Smith 2006-06-13 15:21:24 +00:00
parent 27e50e2ae4
commit ebfa3e3d2f
2 changed files with 29 additions and 4 deletions

View file

@ -40,6 +40,7 @@
- fix: EMS Prerequisite Cache Stale
- Fixed a macro processing problem on the Redirect asset.
- Added a log info entry when a redirect occurs.
- Better handling of automated messages and post bounces for CS Mail.
6.99.3

View file

@ -1,4 +1,4 @@
package WebGUI::Mail::Get;
package WebGUI::Mail::Get;
=head1 LEGAL
@ -152,19 +152,38 @@ sub getNextMessage {
return undef;
}
my $head = $parsedMessage->head;
return $self->getNextMessage if ($head->get("X-Autogenerated")); # drop autogenerated messages
# try to detect auto generated messages and drop them
my $skipAuto = 0;
my @headlines = split("\n",$head->stringify);
foreach my $headline (@headlines) {
$skipAuto = 1 if ($headline =~ m/^X-Auto/);
$skipAuto = 1 if ($headline =~ m/^X-Mirror/);
}
my $returnPath = $head->get("Return-Path");
chomp($returnPath);
$skipAuto = 1 if ($returnPath eq "<>");
my $precedence = $head->get("Precedence");
chomp($precedence);
$skipAuto = 1 if ($precedence eq "bulk");
$skipAuto = 1 if ($precedence eq "junk");
$skipAuto = 1 if ($head->get("Content-Type") =~ m/multipart\/report/);
$skipAuto = 1 if ($head->get("Content-Type") =~ m/report-type=.*delivery-status/);
my $to = $head->get("To") || undef;
chomp($to);
my $from = $head->get("From") || undef;
chomp($from);
my $messageId = $head->get("Message-Id") || undef;
chomp($messageId);
if ($skipAuto) { # drop autogenerated messages
$self->session->errorHandler->info("POP3: Dropped auto generated message ".$messageId." from ".$from." to ".$to);
return $self->getNextMessage;
}
my $cc = $head->get("Cc") || undef;
chomp($cc);
my $subject = $head->get("Subject") || undef;
chomp($subject);
my $inReplyTo = $head->get("In-Reply-To") || $head->get("References") || undef;
chomp($inReplyTo);
my $messageId = $head->get("Message-Id") || undef;
chomp($messageId);
my %data = (
to => $to,
from => $from,
@ -180,6 +199,7 @@ sub getNextMessage {
foreach my $part (@parts) {
my $type = $part->mime_type;
next if ($type eq "message/rfc822");
next if ($type eq "message/delivery-status");
my $body = $part->bodyhandle;
my $disposition = $part->head->get("Content-Disposition");
$disposition =~ m/filename=\"(.*)\"/;
@ -192,6 +212,10 @@ sub getNextMessage {
content=>$content
});
}
unless (scalar(@segments) > 0) { # drop empty messages
$self->session->errorHandler->info("POP3: Dropped empty message ".$data{messageId}." from ".$data{from}." to ".$data{to});
return $self->getNextMessage;
}
$data{parts} = \@segments;
return \%data;
}