diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm index 7c0b3b04ecd..34823e0515c 100644 --- a/lib/RT/Interface/Email.pm +++ b/lib/RT/Interface/Email.pm @@ -590,6 +590,8 @@ sub CheckForAutoGenerated { # Per RFC3834, any Auto-Submitted header which is not "no" means # it is auto-generated. my $AutoSubmitted = $head->get("Auto-Submitted") || ""; + chomp $AutoSubmitted; + $AutoSubmitted =~ s/^\s+|\s+$//g; return 1 if length $AutoSubmitted and $AutoSubmitted ne "no"; # First Class mailer uses this as a clue. diff --git a/t/mail/autogenerated.t b/t/mail/autogenerated.t index a37c9b12dc2..bce3d039c0f 100644 --- a/t/mail/autogenerated.t +++ b/t/mail/autogenerated.t @@ -19,4 +19,13 @@ ok RT::Interface::Email::CheckForAutoGenerated($msg->head), "Is AutoGenerated"; $msg->head->delete("Precedence", 1); ok !RT::Interface::Email::CheckForAutoGenerated($msg->head), "Isn't AutoGenerated"; +$msg->head->set("Auto-Submitted", 'yes'); +ok RT::Interface::Email::CheckForAutoGenerated($msg->head), "Is AutoGenerated"; + +$msg->head->set("Auto-Submitted", 'no'); +ok !RT::Interface::Email::CheckForAutoGenerated($msg->head), "Isn't AutoGenerated, as 'no'"; + +$msg->head->delete("Auto-Submitted"); +ok !RT::Interface::Email::CheckForAutoGenerated($msg->head), "Isn't AutoGenerated, no header"; + done_testing;