Name

ConnectOnlyTo

Synopsis

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 ...

Get Sendmail, 3rd 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.