Sendmail for Multi-Installation Server

We have two production Sakai installations running on a single server and needed to configure sendmail to forward requests to the appropriate instance. Each installation uses a different virtual host, for example, sakfoo.myorg.edu and sakbar.myorg.edu. Mail sent to either host is handled by sendmail on port 25, configured to relay the mail to the appropriate instance. The hostnames are set in the sakai.properties along with the appropriate james port settings:

sakai.properties

sakfoo.myorg.edu
...
# the DNS name of the server
serverName=sakfoo.myorg.edu
...
# SMTP port on which James runs.  Default is 25.  Recommend running on 8025, and using a standard mailer on 25 to forward mail to Sakai.
smtp.port = 8025
...
sakbar.myorg.edu
...
# the DNS name of the server
serverName=sakbar.myorg.edu
...
# SMTP port on which James runs.  Default is 25.  Recommend running on 8025, and using a standard mailer on 25 to forward mail to Sakai.
smtp.port = 8125
...

sendmail

access

I'm not sure if this is required (or even recommended), but we have the hostname for each listed as a relay in access:

localhost.localdomain           RELAY
localhost                       RELAY
127.0.0.1                       RELAY
sakfoo.myorg.edu                RELAY
sakbar.myorg.edu                RELAY
mailertable

This file specifies special delivery mechanisms for individual hosts. In this case, since we have two different installations that will require delivery, we specify a custom handler for each:

sakfoo.myorg.edu     esmtpfoo:[localhost]
sakbar.myorg.edu     esmtpbar:[localhost]
sendmail.mc

Add the handler definitions to the end of sendmail.mc:

MAILER_DEFINITIONS
Mesmtpfoo,       P=[IPC], F=mDFMuXak, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,
                 T=DNS/RFC822/SMTP,
                 A=TCP $h 8025
Mesmtpbar,       P=[IPC], F=mDFMuXak, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,
                 T=DNS/RFC822/SMTP,
                 A=TCP $h 8125
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.