Sendmail Configuration Files – sendmail.cf and sendmail.mc
Sendmail configuration files are located by default in /etc/mail/. PureMessage uses /opt/pmx4/sendmail/etc/mail/
The main configuration file is sendmail.cf. This is a rather cryptic file which we will not configure directly. If you want to know the syntax for sendmail.cf, read the doc at http://www.sendmail.org or get the O’Reily book. This information is specific to the MC file from which a macro builds the CF file..
sendmail.mc contains instructions to allow the M4 macro processor to build sendmail.cf. Very important, before you can use a macro to create a sendmail.cf file, you need to have the macro installed. This is the sendmail package sendmail-cf. To ascertain if the package has been installed on RedHat:
[root@LJLLX001 mail]# rpm -qa | grep sendmail
sendmail-8.13.1-2
sendmail-cf-8.13.1-2
Both sendmail and sendmail-cf packages should appear in the results. If you do not have the CF package, install it.
The text “dnl” within sendmail.mc denotes a comment – like a tic in VisualBasic or a hash in perl. Many lines end with dnl, or dnl with some type of commentary. Lines beginning with dnl are not processed.
Common instructions within a sendmail.mc file:
include(`/usr/share/sendmail-cf/m4/cf.m4′)dnl
This line refers the m4 utility to the correct “translation” to build the sendmail.cf file. Important that the line is at the top of the mc file, but nothing to do with sendmail configuration specifically
VERSIONID(`setup for Red Hat Linux’)dnl
This line is not required, and we have ‘junk’ in it frequently. It records the version of sendmail in the cf file for administrative reference.
OSTYPE(`linux’)dnl
More instructions for m4, different OS’s have different locations for sendmail files and the OS defined here identifies which parameters to use. This line again needs to be at the top of the mc file
define(`confDEF_USER_ID’,“8:12”)dnl
Defines which user and group sendmail will run as – do NOT pick root here. User id 8 (mail) and group id 12 (mail) from /etc/passwd and /etc/groups respectively.
define(`confTO_CONNECT’, `1m’)dnl
Time limit for SMTP connection timeout, set to one minute normally. This is how long your server will wait for an initial connect() to complete.
define(`confTRY_NULL_MX_LIST’,true)dnl
Email is normally routed by MX records. This instruction means the ‘domain’ can also be a host name with no MX defined. E.G. sending email to @windstream.com will return the MX records, as they exist. Attempting to email @neohtwnlx810.windstream.com will return no MX records, but LX810 will be contacted directly to attempt delivery. This is a most useful instruction for return delivery to system mailers.
define(`confDONT_PROBE_INTERFACES’,true)dnl
The sendmail class w lists the host and IP addresses for which sendmail accepts and takes local delivery. This class can be automatically populated, or using this directive not automatically populated. We configure this information manually in other files.
You can use a sendmail command line to determine what is set to various system variables:
[root@LJLLX001 ~]# sendmail -d0.1 -bv
Version 8.13.1
Compiled with: DNSMAP HESIOD HES_GETMAILHOST LDAPMAP LOG MAP_REGEX
MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
NETUNIX NEWDB NIS PIPELINING SASLv2 SCANF STARTTLS TCPWRAPPERS
USERDB USE_LDAP_INIT
============ SYSTEM IDENTITY (after readcf) ============
(short domain name) $w = LJLLX001
(canonical domain name) $j = LJLLX001.vibiant.dnsalias.com
(subdomain name) $m = vibiant.dnsalias.com
(node name) $k = LJLLX001.vibiant.com
========================================================
define(`PROCMAIL_MAILER_PATH’,`/usr/bin/procmail’)dnl
Exactly what it says – the location of procmail
define(`ALIAS_FILE’, `/etc/aliases’)dnl
Location of the file for local delivery aliases – not something we use often as there are few local delivery accounts. In the ISP, this file can be used to give someone additional addresses which deliver to the same mailbox. This file can also be used to direct delivery of a local account to a program – in PureMessage for example, /opt/pmx4/sendmail/etc/mail/aliases directs the pmx-auto-approve address to the application which releases user messages.
define(`confBIND_OPTS’, `WorkAroundBrokenAAAA’)dnl
This is a resolver option, it instructs sendmail to ignore SERVFAIL errors during an IPv6 lookup. We had a few domains for which we could not deliver mail without this directive.
define(`SMART_HOST’, `[192.168.1.53]’)
A smart host can be used instead of direct mail delivery. For a server which is not meant to deliver mail to the internet (neohtwnlx824 for instance) the smart_host directive sends all mail to the defined destination. The destination can be a hostname or an IP address. Note, the mailertable will override the smarthost.
define(`STATUS_FILE’, `/var/log/mail/statistics’)dnl
Retains statistical information on server – use the command mailstats to output the statistics, the file created here is not text
define(`UUCP_MAILER_MAX’, `2000000′)dnl
Maximum size for messages relayed by UUCP mailers
define(`confPRIVACY_FLAGS’, `authwarnings,novrfy,noexpn,restrictqrun’)dnl
Disables unwanted commands – usually for security reasons. EXPN expands groups into component members, for instance, so NOVRFY is used to disable the command. Some of these are more important if local delivery is handled by the sendmail server.
define(`confAUTH_OPTIONS’, `A’)dnl
What kinds of authentication are supported by the server. Useful if you are requiring authentication to relay mail, we do not do this. Some UNIX hosts get confused if AUTH is an option made available, and you need to remark this line out of the mc file.
define(`confTO_QUEUEWARN’, `6d’)dnl
If you ever see an email from a destination mail server saying it is still trying to deliver your message and just wanted to let you know – that is what this interval defines. To truly adhere to RFC specifications, a sendmail server should continue to attempt delivery for at least four to five days. As a “nice” feature, the server can send periodic notifications to the sender that delivery has been delayed. This standard comes from a time when circuits were smaller and quite lossy. It could reasonably take days to establish a connection to the destination and transmit a message.
We are rogue and just return mail as undeliverable after a shorter period. No reason to notify users, but to ensure that a notification is not sent, we put the warning interval at something higher than the expiration interval.
define(`confTO_QUEUERETURN’, `12h’)dnl
Related to the QUEUEWARN interval – this is the period after which the sendmail server considers the message undeliverable and returns it to the sender. By default, this is five days so we make sure to define something more reasonable. Otherwise there would be no way to identify “high” mail queue counts for alerting.
define(`confQUEUE_LA’, `16′)dnl
Load average at which queue only functionality is engaged
define(`confREFUSE_LA’, `48′)dnl
Load average at which SMTP connections are refused
define(`confDELAY_LA’, `30′)dnl
Load average at which sendmail will delay one second on SMTP commands
define(`confMIN_QUEUE_AGE’, `5m’)dnl
Minimum time a message has to sit in the queue before it is retried
define(`confTO_HOSTSTATUS’, `2m’)dnl
If a host has been denoted as unavailable, the status will be cached for this duration. After the interval expires, connection to the host will be retried
define(`confMAX_DAEMON_CHILDREN’, 2000)
Maximum number of children processes permitted. Sendmail will reject subsequent connections once this number has been reached. Very important to have something defined on the DMZ servers. Default is infinite and it is possible for a server to become unresponsive and need to be rebooted with out of memory errors when too many processes are spawned.
define(`confTO_IDENT’, `0′)dnl
Timeout for responses to IDENT
FEATURE(`no_default_msa’,`dnl’)dnl
The default MSA options are not used, but rather explicitly defined in the DAEMON_OPTIONS directive
FEATURE(`smrsh’,`/usr/sbin/smrsh’)dnl
Shell used for command line mailing programs, not really pertinent in our case
FEATURE(`mailertable’,`hash -o /etc/mail/mailertable.db’)dnl
This file will be discussed in more detail later, this directive specifies the use of a mailertable and the location of the file.
VIRTUSER_DOMAIN_FILE(/etc/mail/virtuser-domains)dnl
This file will be discussed in more detail later, this directive specifies the location of the file containing virtualised domains
FEATURE(`virtusertable’,`hash -o /etc/mail/virtusertable.db’)dnl
This file will be discussed in more detail later, this directive specifies the use of virtual user mapping and the location of the file containing said mappings
FEATURE(always_add_domain)dnl
Appends the local host domain to even locally delivered mail.
FEATURE(use_cw_file)dnl
Alternate host names are in /etc/mail/local-host-names – machine aliases
FEATURE(use_ct_file)dnl
Users who can set alternate envelope from addresses without generating a warning message. File is /etc/mail/trusted-users
FEATURE(local_procmail,`’,`procmail -t -Y -a $h -d $u’)dnl
Specifies program to use as the local mailer, and command options
FEATURE(`access_db’,`hash -T<TMPF> -o /etc/mail/access.db’)dnl
This file will be discussed in more detail later, this directive specifies the use of an access restriction table and the location of the file.
EXPOSED_USER(`root’)dnl
DAEMON_OPTIONS(`Port=smtp, Name=MTA’)dnl
This is where the settings for the MSA are defined. Port=smtp uses the default port of 25, or an alternate port can be used. Addr=# can be included to bind sendmail to a specific address (including 127.0.0.1 for localhost access only).
INPUT_MAIL_FILTER(`vamilter’,`S=inet:3333@localhost,F=R,T=S:10m;R:10m;E:10m’)
Defines a “milter” – mail filter. The port and destination of the milter must be included with S=. S=inet is a IPv4 socket, S=inet6 is an IPv6 socket, and S=local is a Unix-domain socket (/var/run/)
F= defines an action to take on failure, R (reject), T (tempfail), or if no option is included just pass the message through sendmail and ignore the milter
T= defines timeouts for sendmail’s communication with the milter:
C Connect timeout
S Sending timeout (sendmail transmission of data to milter)
R Reading timeout (for reply from milter)
E Overall timeout (between sending end of message and final ack)
MASQUERADE_AS(`vibiant.dnsaliascom’)dnl
FEATURE(`masquerade_envelope’)dnl
FEATURE(`allmasquerade’)dnl
MASQUERADE_DOMAIN(`arlitljl.com’)dnl
MASQUERADE_DOMAIN(`homedomain.local’)dnl
This group of directives are all interrelated. Masquerading is basically replacement – MASQUERADE_AS is the domain which will be used in place of the domains identified in MASQUERADE_DOMAIN lines. In this case, both @arlitljl.com and @homedomain.local will be overwritten with @vibiant.dnsalias.com. The directive FEATURE(masquerade_entire_domain) could be included to replace any subdomain of the masquerade domains (e.g. @secured.arlitljl.com, @public.arlitljl.com, and @restricted.arlitljl.com in addition to @arlitljl.com)
Masquerade envelope applies the masquerade to the envelope information and allmasquerade applies the masquerade to everything in the envelope, including cc:, from: and to: — this directive is important when we mask an acquired company’s email domain with our own.
FEATURE(`accept_unresolvable_domains’)dnl
Allows the use of domains in the MAIL FROM command to be invalid network and sender domains. Since some people do not manage to configure their mail servers properly, we are less restrictive here to avoid complaints.
LOCAL_DOMAIN(`localhost.localdomain’)dnl
Domain(s) for which the server will accept local delivery – since our servers do not really deliver mail the domain should include the localdomain to prevent accidental misdirection of mail
MAILER(smtp)dnl
MAILER(procmail)dnl
Defines mailers to be used in addition to local – these should be the last lines of the mc file
When you make changes to the sendmail.mc file, you will need to run the macro processor to update the CF file. You can see the results by running:
m4 sendmail.mc | less
The text which will be used in sendmail.cf will be displayed on the screen. To actually commit the changes, use:
m4 sendmail.mc > sendmail.cf
or just type
make
Make will update all of the files in /etc/mail, so ensure you like all the changes you have made, not just the changes to sendmail.mc