Sometimes it is necessary to test sendmail
without allowing mail to be delivered or relayed offsite. In the
ideal test situation, it is preferable that the recipient and sender
addresses are not modified in the process. After all, one needs to be
sure that all headers will be correct, and that all necessary rule
sets will be exercised.
The ConnectOnlyTo option provides just such a
service by allowing all mail to be relayed to a single machine,
regardless of how the mail is addressed. It is declared like this:
O ConnectOnlyTo=ipaddr configuration file (V8.10 and later)
-OConnectOnlyTo=ipaddr command line (V8.10 and later)
define(`confCONNECT_ONLY_TO',`ipaddr') mc configuration (V8.10 and later)
Here, ipaddr is the IP addresses of the
target machine to which all mail will be delivered. It must be given
in the form of a dotted quad unless sendmail was
compiled with NETINET6 (NET...) defined, in
which case you can specify an IPv6 address.
The ConnectOnlyTo option can be used when testing,
and commented out otherwise. The ConnectOnlyTo
option should not be confused with the nullclient
or msp features, which send all mail to a hostname
that can use MX records, and thus is more versatile and does a
superior job of forwarding mail to a dedicated mail server.
An easy way to create a target for the
ConnectOnlyTo option's setting
that accepts all SMTP mail, but logs and discards each inbound piece,
is to add the following to a new and separate mc
configuration file (don't change your main
configuration file):
LOCAL_RULESETS
SLocal_check_rcpt
R$* $#discard
This setup will cause all inbound SMTP mail to be discarded. Logs
will include lines that look (in part) like this:
ruleset=check_rcpt, arg1=<recipient>, relay=host [addr], discard
If you set up a host this way, however, understand that you should
probably use a setup that is fully separate from the normal one. That
way, user outbound email will still work.
The ConnectOnlyTo option is not safe. If specified
from the command line, it can cause sendmail to
relinquish its special privileges.