LP1532236 Evergreen should allow for HTML formatted action trigger emails
authorblake <blake@mobiusconsortium.org>
Mon, 17 Feb 2020 15:10:17 +0000 (09:10 -0600)
committerJane Sandberg <sandbergja@gmail.com>
Mon, 5 Sep 2022 17:04:19 +0000 (10:04 -0700)
Simple fix for allowing the AT template to drive the email headers instead
of replacing the headers blindly. Kudos to tsbere for the unless idea.

Testing: setup an action trigger for SendEmail. Make sure your AT template includes
an email header (EG: Content-Type: text/html;charset=utf-8)
Setup a hold/circulation that meets the criteria of your action trigger. Check the
resuting email's headers to match what you had put into the template.

Signed-off-by: blake <blake@mobiusconsortium.org>
Signed-off-by: Garry Collum <gcollum@gmail.com>
Signed-off-by: Jane Sandberg <sandbergja@gmail.com>

Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/SendEmail.pm

index 17cca23..71354e6 100644 (file)
@@ -90,9 +90,9 @@ sub handler {
     my @headers = $email->header('Subject');
     $email->header_str_set('Subject' => decode_utf8($headers[0])) if ($headers[0]);
 
-    $email->header_set('MIME-Version' => '1.0');
-    $email->header_set('Content-Type' => "text/plain; charset=UTF-8");
-    $email->header_set('Content-Transfer-Encoding' => '8bit');
+    $email->header_set('MIME-Version' => '1.0') unless $email->header('MIME-Version');
+    $email->header_set('Content-Type' => "text/plain; charset=UTF-8") unless $email->header('Content-Type');
+    $email->header_set('Content-Transfer-Encoding' => '8bit') unless $email->header('Content-Transfer-Encoding');
 
     try {
         $stat = $sender->send($email);