[Rt-commit] rt branch, 4.0/outgoing-mail-from, created. rt-4.0.7-59-g143fddb

Thomas Sibley trs at bestpractical.com
Wed Sep 12 16:44:03 EDT 2012


The branch, 4.0/outgoing-mail-from has been created
        at  143fddb586bdbb4483f755520edadb9fa6fdd323 (commit)

- Log -----------------------------------------------------------------
commit 79a039f9d2a9006d5a61e9732224a41e27ba06de
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Sep 12 13:13:02 2012 -0700

    OverrideOutgoingMailFrom: Use $CorrespondAddress if the queue's isn't set
    
    Otherwise the meaning of the Default key changes depending on the
    queue's correspond address being set or not.  Using the global
    correspond address for queues with no specific correspond address, as
    well as moving the Default check into the else branch, means the Default
    key is only used when there's no ticket involved.  This is the
    documented behaviour in RT_Config.pm.

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 9270462..4c5ca1f 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -420,12 +420,13 @@ sub SendEmail {
                 if ($QueueAddressOverride) {
                     $OutgoingMailAddress = $QueueAddressOverride;
                 } else {
-                    $OutgoingMailAddress = $TicketObj->QueueObj->CorrespondAddress;
+                    $OutgoingMailAddress = $TicketObj->QueueObj->CorrespondAddress
+                                           || RT->Config->Get('CorrespondAddress');
                 }
+            } else {
+                $OutgoingMailAddress ||= RT->Config->Get('OverrideOutgoingMailFrom')->{'Default'};
             }
 
-            $OutgoingMailAddress ||= RT->Config->Get('OverrideOutgoingMailFrom')->{'Default'};
-
             push @args, "-f", $OutgoingMailAddress
                 if $OutgoingMailAddress;
         }

commit 143fddb586bdbb4483f755520edadb9fa6fdd323
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Sep 12 13:28:37 2012 -0700

    SetOutgoingMailFrom: Accept an email address as a value and use it globally
    
    Covers the simple case of sending all bounces to a specific address,
    without the only previous solution of resorting to defining all queues
    in OverrideOutgoingMailFrom.  Any definitions in the Override option
    still take precedence.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 317202d..50e6f23 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -495,6 +495,12 @@ Correspond mail address of the ticket's queue.
 Warning: If you use this setting, bounced mails will appear to be
 incoming mail to the system, thus creating new tickets.
 
+If the value contains an C<@>, it is assumed to be an email address and used as
+a global envelope sender.  Expected usage in this case is to simply set the
+same envelope sender on all mail from RT, without defining
+C<$OverrideOutgoingMailFrom>.  If you do define C<$OverrideOutgoingMailFrom>,
+anything specified there overrides the global value (including Default).
+
 =cut
 
 Set($SetOutgoingMailFrom, 0);
diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 4c5ca1f..439efb4 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -410,21 +410,23 @@ sub SendEmail {
         # SetOutgoingMailFrom and bounces conflict, since they both want -f
         if ( $args{'Bounce'} ) {
             push @args, shellwords(RT->Config->Get('SendmailBounceArguments'));
-        } elsif ( RT->Config->Get('SetOutgoingMailFrom') ) {
-            my $OutgoingMailAddress;
+        } elsif ( my $MailFrom = RT->Config->Get('SetOutgoingMailFrom') ) {
+            my $OutgoingMailAddress = $MailFrom =~ /\@/ ? $MailFrom : undef;
+            my $Overrides = RT->Config->Get('OverrideOutgoingMailFrom') || {};
 
             if ($TicketObj) {
                 my $QueueName = $TicketObj->QueueObj->Name;
-                my $QueueAddressOverride = RT->Config->Get('OverrideOutgoingMailFrom')->{$QueueName};
+                my $QueueAddressOverride = $Overrides->{$QueueName};
 
                 if ($QueueAddressOverride) {
                     $OutgoingMailAddress = $QueueAddressOverride;
                 } else {
-                    $OutgoingMailAddress = $TicketObj->QueueObj->CorrespondAddress
-                                           || RT->Config->Get('CorrespondAddress');
+                    $OutgoingMailAddress ||= $TicketObj->QueueObj->CorrespondAddress
+                                             || RT->Config->Get('CorrespondAddress');
                 }
-            } else {
-                $OutgoingMailAddress ||= RT->Config->Get('OverrideOutgoingMailFrom')->{'Default'};
+            }
+            elsif ($Overrides->{'Default'}) {
+                $OutgoingMailAddress = $Overrides->{'Default'};
             }
 
             push @args, "-f", $OutgoingMailAddress

-----------------------------------------------------------------------


More information about the Rt-commit mailing list