Bug 25765: (QA follow-up) Save a DB hit
[srvgit] / Koha / Email.pm
index 5834075..f1e825e 100644 (file)
@@ -2,23 +2,24 @@
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 package Koha::Email;
 
 use Modern::Perl;
 use Email::Valid;
+use Email::MessageID;
 
 use base qw(Class::Accessor);
 use C4::Context;
@@ -55,8 +56,8 @@ sub create_message_headers {
         $mail{'To'} = C4::Context->preference('SendAllEmailsTo');
     }
     else {
-        $mail{'Cc'} = $params->{cc};
-        $mail{'Bcc'} = $params->{bcc};
+        $mail{'Cc'}  = $params->{cc}  if exists $params->{cc};
+        $mail{'Bcc'} = $params->{bcc} if exists $params->{bcc};
     }
 
     if ( C4::Context->preference('ReplytoDefault') ) {
@@ -70,6 +71,8 @@ sub create_message_headers {
     $mail{'Message'}      = $params->{message}     if $params->{message};
     $mail{'Subject'}      = $params->{subject}     if $params->{subject};
     $mail{'Content-Type'} = $params->{contenttype} if $params->{contenttype};
+    $mail{'X-Mailer'}     = "Koha";
+    $mail{'Message-ID'}   = Email::MessageID->new->in_brackets;
     return %mail;
 }
 1;