Allow to override 'envelope from' 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

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

Does $OverrideOutgoingMailFrom not provide enough rope for your use
case? It lets you change envelope from on a per-queue basis

-kevin

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

Does $OverrideOutgoingMailFrom not provide enough rope for your use
case? It lets you change envelope from on a per-queue basis

No. I need to override it on Template basis. I have two separate Scrips
that can execute on same event and use these two separate Templates.
Thus one event can generate two mails with separate envelope from.

  • Timo

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

Does $OverrideOutgoingMailFrom not provide enough rope for your use
case? It lets you change envelope from on a per-queue basis

No. I need to override it on Template basis. I have two separate Scrips
that can execute on same event and use these two separate Templates.
Thus one event can generate two mails with separate envelope from.

Ok, can you send it as a patch against master to rt-bugs after you
fold the header parsing into the if block which is the only place you
use that variable? I’ll see that it gets assigned to get looked at
for the 4.2 series.

Thanks

-kevin

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

Does $OverrideOutgoingMailFrom not provide enough rope for your use
case? It lets you change envelope from on a per-queue basis

No. I need to override it on Template basis. I have two separate Scrips
that can execute on same event and use these two separate Templates.
Thus one event can generate two mails with separate envelope from.

Ok, can you send it as a patch against master to rt-bugs after you
fold the header parsing into the if block which is the only place you
use that variable? I’ll see that it gets assigned to get looked at
for the 4.2 series.

Ok, will do. Though $args is redefined in that if block, so it’s not
convenient to access the headers there… Maybe I should rename the
$args in the if block while at it.

  • Timo