I ended up not using Sendmail for this after all. Instead I installed Postfix using a Slackbuild from Slackbuilds.org and enabled it to relay to my Exchange server.
The first step was adding an additional transport in /etc/postfix/master.cf that looked like:
Code:
smtp2 unix - - n - - smtp -o smtp_generic_maps=regexp:/etc/postfix/generic_smtp2
Then I added this line to /etc/postfix/main.cf:
Code:
transport_maps=regexp:/etc/postfix/transport
Next I added this to /etc/postfix/transport:
Code:
/@domainB\.com/ smtp2:[<IP or Name of Exchange Server>]
That line tells it to use my new transport for any mail addressed to someone @domainB.com.
Created and edited /etc/postfix/generic_smtp2 to look like:
Code:
/^(.*)@domainA\.com/ $1@domainB.com
Finally ran
Code:
postmap /etc/postfix/generic_smtp2
and restarted postfix.
Now any messages from domainA.com to users at domainA.com are unaffected. But if the email is addressed to someone at domainB.com, then the sender address is rewritten to look like it's from domainB.com as well.
I had to actually create a user account in Exchange for the address after it gets rewritten (such as
application@domainB.com) so that if a user replies, it actually goes to a mailbox.