How to send correspondance from different email address based on queue?

I use Postfix for my localhost MTA on my RT server, and this works fine to relay to my Barracuda service for all RT outbound mails.

But now I have a queue for a different organization, and the email address for this queue is a different domain on Office 365. I set the queue response address in the RT UI to this address, but naturally these emails are ending up in spam because my Barracuda service is not authorized to send from that domain.

So I tried to make my postfix conditionally use a “sender specific transport” so if emails are from support@NEWCOMPANYQUEUE.com it will use the office365 SMTP server with authentication.

But this did not work, I think because ALL emails from RT are currently having an Envelope Sender which is “www-data” instead of the correct From: address .

I could maybe fix this with the RT config option SendMailArguments “-f support@oldcompany.com” , but this would not solve my original problem, where I need outbound mail to use a different envelope sender and ultimately different outbound SMTP server for that queue …

Please help! Thanks

Set($RTAddressRegexp,qr{^(?:RTIRAlerts@domain.com)$}i);
Set( $SendmailPath , ‘/usr/sbin/sendmail’);
Set( $CorrespondAddress , ‘RTIRAlerts@domain.com’);
Set( $CommentAddress ,‘RTIRAlerts@domain.com’);
This is what i use in RT_SiteConfig.pm

Take a look at the $SetOutgoingMailFrom and $OverrideOutgoingMailFrom config options. They are used to control for envelope sender.

https://docs.bestpractical.com/rt/4.4.1/RT_Config.html#Outgoing-mail

/Lars