MaxHopCount

Set maximum hop count All versions

A hop is the transmittal of a mail message from one machine to another.[394] Many hops might be required to deliver a message. The number of hops is determined by counting the Received:, Via:, X400-Received, and Mail-From: lines in the header of an email message.[395]

The MaxHopCount option tells sendmail the maximum number of times a message can be forwarded. When sendmail receives a message via email, it calculates the hop count. If that count is above the maximum allowed, it bounces the message back to the sender with the error:

sendmail: too many hops (17 max)

In this case, 17 is the maximum. Detecting too many hops is useful in stopping mail loops—messages being forwarded back and forth between two machines.

The forms of the MaxHopCount option are as follows:

O MaxHopCount=hopsconfiguration file (V8.7 and later)
-OMaxHopCount=hopscommand line (V8.7 and later)
define(`confMAX_HOP',hops)   ← mc configuration (V8.7 and later)
Ohhopsconfiguration file (deprecated)
-ohhopscommand line (deprecated)

The hops argument is of type numeric. If hops is missing, the value becomes zero and causes all mail to fail with the error:

sendmail: too many hops (0 max)

If the entire MaxHopCount option is missing, hops defaults to 25. A good value is 50 or more (RFC2821, Command-Line Switches, suggests 100). This allows mail to follow a fairly long route through many machines (as it could with UUCP) but still catches and bounces mail caught in a loop ...

Get sendmail, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.