How to deliver mail to destination on different port (other than 25) using sendmail

I have came across this requirement for a client PoC. Requirement is to setup a route in sendmail for a subdomain (abcd.ourdomain.com) to deliver mails to the project team’s SAP server, which is…I have came across this requirement for a client PoC. Requirement is to setup a route in sendmail for a subdomain (abcd.ourdomain.com) to deliver mails to the project team’s SAP server, which is running it’s built-in SMTP service on port 24999 rather than on port 25 (this is default design because SAP developers wanted SAP not be be used as a MTA). As we know already, sendmail will deliver the mail to destination mentioned in mailertable on port 25 by default.

But, as project team, can’t change the port in SAP, we wanted to modify sendmail configuration such that it delivers mails to SAP server on port 24999. I went through sendmail cookbook earlier so suddenly i came to know that we can use a different mailer (the mail delivery agent) i.e., we can create a new mail delivery agent (sendmail allows us to create and use multiple delivery agents).
Here is the definition i have added to sendmail.mc (all steps).

# vi /etc/mail/sendmail.mc
define(`confSAPRELAY_MAILER’, `esmtp’)
define(`SAPRELAY_MAILER_ARGS’, `TCP $h 24999′)
Equivalent sendmail.cf line after generating new sendmail.cf file using m4 is
Msaprelay, P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990, T=DNS/RFC822/SMTP, A=TCP $h 24999

# vi /etc/mail/mailertable
abcd.ourdomain.com saprelay:[abcd.ourdomain.com]
# make -C /etc/mail
# service sendmail restart

After restarting service, and sending a test mail, mail is delivered to SAP server on port 24999.

Happy Learning,
Ramesh  mailto.d.ramesh@gmail.com>,

Advertisements