From 492a7b7ed5881b827a48857cec2f315d155fddc8 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Thu, 30 Aug 2012 16:35:18 +0800 Subject: Add x-generated-by header to bugmail --- Bugzilla/BugMail.pm | 5 +++++ Bugzilla/Mailer.pm | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index 521291380..696db5ceb 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -48,6 +48,7 @@ use Date::Parse; use Date::Format; use Scalar::Util qw(blessed); use List::MoreUtils qw(uniq firstidx); +use Sys::Hostname; use constant BIT_DIRECT => 1; use constant BIT_WATCHING => 2; @@ -465,6 +466,10 @@ sub _generate_bugmail { # TT trims the trailing newline, and threadingmarker may be ignored. my $email = new Email::MIME("$msg_header\n"); + + # For tracking/diagnostic purposes, add our hostname + $email->header_set('X-Generated-By' => hostname()); + if (scalar(@parts) == 1) { $email->content_type_set($parts[0]->content_type); } else { diff --git a/Bugzilla/Mailer.pm b/Bugzilla/Mailer.pm index 74c9010c2..d27f79155 100644 --- a/Bugzilla/Mailer.pm +++ b/Bugzilla/Mailer.pm @@ -49,6 +49,7 @@ use Encode::MIME::Header; use Email::Address; use Email::MIME; use Email::Send; +use Sys::Hostname; sub MessageToMTA { my ($msg, $send_now) = (@_); @@ -142,6 +143,12 @@ sub MessageToMTA { } } + # For tracking/diagnostic purposes, add our hostname + my $generated_by = $email->header('X-Generated-By') || ''; + if ($generated_by =~ tr/\/// < 3) { + $email->header_set('X-Generated-By' => $generated_by . '/' . hostname() . "($$)"); + } + if ($method eq "SMTP") { push @args, Host => Bugzilla->params->{"smtpserver"}, username => Bugzilla->params->{"smtp_username"}, -- cgit v1.2.3-24-g4f1b