Routing mail to a specific host on a specific port

Standard

added 3.19.2002 — written by David van Geyn (original location http://freebsd.peon.net/tutorials/20/)——————————————————————————–
Article Description: This document will briefly describe how to set up Sendmail on one host to route to another mail host on a port different than 25.
——————————————————————————–
I was faced with a mail dilemma recently. My provider suddenly decided to block port 25 inbound for all ‘residential’ customers. This posed a problem for me, because I was routing all mail for me through the computer that was now blocked.

Luckily, I have access to a colocated box and was able to route mail there instead, until I figured out a way to get the mail eventually delivered to the proper box.

I searched the archives of ‘comp.mail.sendmail’ on Usenet and found what I was looking for.

A way to use mailertable to route mail to the specified host on a different port.

NOTE: Any occurence of ‘940’ in this document can be changed to whatever port you want to use.

1. First, you need to specify another listening port in your sendmail.cf on the blocked host. You can do this by adding the following line:

OOPort=940

This will make sendmail listen on port 940 in addition to port 25.

2. Specify a new ‘relay mail header masquerading recipient rewriting’ line in the sendmail.cf on the host that will be forwarding the mail to your blocked host.

This can be done by first copying the Mesmtp rewriter that looks like this:

Mesmtp, P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,
T=DNS/RFC822/SMTP,
A=TCP $h

Next, modify it to look like this:

Mesmtp940, P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,
T=DNS/RFC822/SMTP,
A=TCP $h 940

3. Now, you need to add your entry to your mailertable and indicate that you want to use ‘esmtp940’ instead of just ‘esmtp’.

example-domain.com esmtp940:[mx-blocked.example-domain.com]

4. Make sure example-domain.com has been added to your relay-domains file, otherwise the host that will receive mail on port 25 will not accept any mail for that domain.

5. Restart sendmail. Try sendmail some mail and see if your unblocked host will forward mail it receives for the domain to the blocked host on port 940.

This setup works perfectly for me. If you have any questions, comments, or suggestions let me know via ‘Feedback’.

Good luck!


——————————————————————————–

NOTE ADDED October 4, 2002

The following is a comment from an e-mail sent to me by a visitor of the site.

I received an e-mail from a visitor indicating that even though they’d added the proper things to ‘sendmail.cf’ and mailertable, the mail was still being delivered locally. The solution to this problem was to remove the domain that was supposed to be forwarded from the ‘local-host-names’ file and add it instead to the ‘relay-domains’ file.


——————————————————————————–

NOTE ADDED November 1, 2002

The following is an excerpt from an e-mail sent to me by a visitor of the site.

This is an excellent tutorial but I found that I got the dreaded ‘unknown mailer’ error (sendmail 8.12) until I actually edited the ‘smtp.m4’ file and used this to ‘Make’ a new ‘sendmail.cf’ file. The change to the ‘smtp.m4’ file that I made was very simple, I just copied the ‘esmtp’ entry at the foot of the file and pasted it with a name of my choice … this is then in the ‘sendmail.cf’ file that is created via ‘Make’; just add the port to the ‘A=TCP $h port#’ line and away you go.

Hope this helps anyone out there with Sendmail 8.12.x.

 


Disclaimer:
By reading and/or using the information within this web page you agree to hold the author, publisher and all related entities harmless from any claim directly or indirectly related to the information given or the use of any part of the information on this web site. Use at own risk. No responsibility taken.