[Rt-devel] [PATCH] Allow to override 'envelope from' from templates

Timo Teräs timo.teras at iki.fi
Wed Jul 6 09:47:10 EDT 2011


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



More information about the rt-devel mailing list