aboutsummaryrefslogtreecommitdiffstats
path: root/main/rt4/0001-email-allow-envelope-from-overriding-from-templates.patch
blob: a7bbf33d9bfa2fcbe3086cddcc772878988c2c99 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From f2f3542e163c534a437944089b801f6134c6b02a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Wed, 6 Jul 2011 09:56:57 +0300
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.
---
 lib/RT/Interface/Email.pm |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 620ca60..8bd94eb 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -343,7 +343,10 @@ sub SendEmail {
 
     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')
@@ -408,16 +411,16 @@ sub SendEmail {
 
         # SetOutgoingMailFrom
         if ( RT->Config->Get('SetOutgoingMailFrom') ) {
-            my $OutgoingMailAddress;
+            my $OutgoingMailAddress = $envelope_from;
 
             if ($TicketObj) {
                 my $QueueName = $TicketObj->QueueObj->Name;
                 my $QueueAddressOverride = RT->Config->Get('OverrideOutgoingMailFrom')->{$QueueName};
 
                 if ($QueueAddressOverride) {
-                    $OutgoingMailAddress = $QueueAddressOverride;
+                    $OutgoingMailAddress ||= $QueueAddressOverride;
                 } else {
-                    $OutgoingMailAddress = $TicketObj->QueueObj->CorrespondAddress;
+                    $OutgoingMailAddress ||= $TicketObj->QueueObj->CorrespondAddress;
                 }
             }
 
-- 
1.7.1