SetOutgoingMailFrom for Comment Addresses

Hi All,

I am having some problems with the $SetOutgoingMailFrom option. I am currently using RT 4.4.2 though as far as I can tell, this hasn’t changed in subsequent versions.

I need sendmail to change the envelope header for outgoing email so that it matches the From address in all cases. We have a number of queues and they each have their own email addresses for correspondence and comments.

I have set up postfix to do “Sender-Dependent SASL Authentication” with Office365. This means when an email is sent from queue1@example.com it authenticates as the queue1 user and if email is sent from queue2@example.com, it authenticates as queue2@example.com.

This works fine with $SetOutgoingMailFrom but breaks when an email is sent because of a comment. Comments are sent from queue1comment@example.com which is a separate Office365 user. This allows us to reply to comments via email and have RT automatically file that as a comment rather than correspondence. The CommentAddress is set accordingly for every queue.

Comments still receive the -f queue1@example.com option to sendmail, NOT -f queue1comment@example.com. Is there a way to override this? Office365 does not allow queue1 to send mail “from” queue1comment. We are not “in charge” of our corporate email so I am trying to fix this on the front-end.

From what I can tell, in /opt/rt4/lib/RT/Inteface/Email.pm, this is the function that returns the required From address:

sub _OutgoingMailFrom {
    my $TicketObj = shift;

    my $MailFrom = RT->Config->Get('SetOutgoingMailFrom');
    my $OutgoingMailAddress = $MailFrom =~ /\@/ ? $MailFrom : undef;
    my $Overrides = RT->Config->Get('OverrideOutgoingMailFrom') || {};

    if ($TicketObj) {
        my $Queue = $TicketObj->QueueObj;
        my $QueueAddressOverride = $Overrides->{$Queue->id}
            || $Overrides->{$Queue->Name};

        if ($QueueAddressOverride) {
            $OutgoingMailAddress = $QueueAddressOverride;
        } else {
            $OutgoingMailAddress ||= $Queue->CorrespondAddress
                || RT->Config->Get('CorrespondAddress');
        }
    }
    elsif ($Overrides->{'Default'}) {
        $OutgoingMailAddress = $Overrides->{'Default'};
    }

    return $OutgoingMailAddress;
}

So, it looks like it always returns $Queue->CorrespondAddress and never $Queue->CommentAddress.

Long story short - am I missing something or is this feature simply not implemented? Is there a clever workaround I am missing? From what I can tell simply modifying the function above is likely not enough since it’s called in such a way that there is no distinction made between Correspondence and Comments.

Our Comment emails are caused by a scrip. Is there some way I can modify this scrip to Set the $OutgoingMailAddress variable?

Thanks for your help,

Markus