Delivering Mail To Sendmail On Different Ports Using SMTP



This is from a posting I made to comp.mail.sendmail

In some environments you may want to deliver to different ports on a specific host based on the host or domainname. I.e. mail to gadget.com should go to port 26 on relay.gadget.com and mail to dohicky.com should go to port 28 on relay.gadget.com.

You could do this with a custom mailer and the mailertable.

Here is the mailer (in M4 format)

	MAILER_DEFINITIONS
	##################################################################
	###   SMTP to a specific port on a host mailer specification   ###
	##################################################################
	Mportredirect,  P=[IPC], F=mDFMuXa, S=11/31, R=21/31, E=\r\n, L=990,
		T=DNS/RFC822/SMTP,
		A=IPC relay.gadget.com $h
		      ^^^^^^^^^^^^^^^^
It is simply the esmtp mailer definition with a new name, portredirect, and a modified A= line. I have added a specific host between IPC and $h. This means that $h will be a port number rather than a host to connect to.

You would then add entries in the mailer table of the form:

	gadget.com	portredirect:26
	dohicky.com	portredirect:28

This would cause mail for user@gadget.com to be delivered to port 26 on host relay.gadget.com and mail to user@dohicky.com to be delivered to port 28 on relay.gadget.com

If you want to connect to the local host remember to add the "k" mailer flag to the F= field to disable the local loopback test. If you do not do this you will get the error message:
   554 MX list for gadget.com points back to relay.gadget.com
   554 user@gadget.com... Local configuration error

Just another "Harker's Helpful Hints"


RLH