Linux – How many entries can be specified in the sendmail SMART_HOST config line

emaillinuxsendmail

CentOS | Sendmail

I have the following line in my sendmail.mc file:

define(`SMART_HOST',`relay:[1.1.1.1]:[2.2.2.2]')

My understanding is that sendmail will always smarthost to 1.1.1.1 and then fail-over to using 2.2.2.2 if necessary.

Can I specify a third entry here? For example:

define(`SMART_HOST',`relay:[1.1.1.1]:[2.2.2.2]:[3.3.3.3]')

What are the limits on how many entries I can specify here?

Best Answer

If you look at the $#relay mailer definition, you will see for example that it is defined as:

Mrelay,         P=[IPC], F=mDFMuXa8, S=EnvFromSMTP/HdrFromSMTP, R=MasqSMTP, E=\r\n, L=2040,
                T=DNS/RFC822/SMTP,
                A=TCP $h

So your question effectively becomes: Can $h be a colon separated list, and if yes, for how many hosts? To which the bat book replies in page 739:

Beginning withV8 sendmail, $h (possibly as returned by the parse rule set 0) can be a colon-separated list of hosts. The sendmail program attempts to connect to each in turn, left to right:

A=TCP hostA:hostB:hostC

Here, it tries to connect to hostA first. If that fails, it next tries hostB, and so on. As usual, trying a host means trying its MX records first, or its A or AAAA record if there are no MX records.

For the actual limit one would have to look at the sendmail sources to verify if any exists.

There is second argument implied in A=TCP $h which is omitted and this is the port number (assumed by default to be 25). You can have a host list and a single port, but I am not sure whether (or how) you can have a host list with a different listening port for incoming connections for each host on the list. For such an elaborate and tricky setup I would write another delivery agent that could make use of this.