summaryrefslogtreecommitdiffstats
path: root/main/rt4/0001-email-allow-envelope-from-overriding-from-templates.patch
blob: 8e5df099c66a3783906609ec5f38e4b35e823d8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Subject: [PATCH] email: allow envelope from overriding from templates

Add X-RT-Envelope-From header that will override the envelope
from if using sendmailpipe mail sending.

diff -ru rt-4.0.15.orig/lib/RT/Interface/Email.pm rt-4.0.15/lib/RT/Interface/Email.pm
--- rt-4.0.15.orig/lib/RT/Interface/Email.pm	2013-07-25 23:09:24.000000000 +0300
+++ rt-4.0.15/lib/RT/Interface/Email.pm	2013-07-27 10:17:42.508546335 +0300
@@ -376,7 +376,10 @@
 
     my $msgid = $args{'Entity'}->head->get('Message-ID') || '';
     chomp $msgid;
-    
+
+    my $envelope_from = $args{'Entity'}->head->get('X-RT-Envelope-From');
+    chomp $envelope_from;
+
     # If we don't have any recipients to send to, don't send a message;
     unless ( $args{'Entity'}->head->get('To')
         || $args{'Entity'}->head->get('Cc')
@@ -442,7 +445,8 @@
                 if ($QueueAddressOverride) {
                     $OutgoingMailAddress = $QueueAddressOverride;
                 } else {
-                    $OutgoingMailAddress ||= $TicketObj->QueueObj->CorrespondAddress
+                    $OutgoingMailAddress ||= $envelope_from
+                                             || $TicketObj->QueueObj->CorrespondAddress
                                              || RT->Config->Get('CorrespondAddress');
                 }
             }