divert(-1)dnl
dnl # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
dnl # Author: A-NAME-HERE
dnl # File: /some/path/sendmail.mc
dnl # Change Log:
dnl # Who When What
dnl # ---- ----------- --------------------------------------------
dnl #
dnl #
dnl #
dnl #
dnl # NOTES: Sendmail book (Chap 4.2.3, page 155) states recommended
dnl # order of entries in .mc file; see Chap 4.1.2 (Page 147)
dnl # concerning "dnl"
dnl #
dnl # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
divert(0)dnl
dnl # Sendmail, Chap 4.2.3.1, Page 155
VERSIONID(`$Id: sendmail.mc, v8.1X.Y 2005/MM/DD HH:MM:SS NAME Exp $')dnl
dnl # Sendmail, Chap 4.2.2.1, Page 152
OSTYPE(YOUR-OS-HERE)dnl
dnl # Sendmail, Chap 4.2.2.3, Page 152
DOMAIN(generic)dnl
######################
## Optional Definitions Section ##
######################
dnl # Sendmail, Chap 24.9.8, Page 951
dnl # As an anti-SPAM measure, instruct daemon that after a sending host
dnl # gives more than one RCPT TO: for a non-existent/invalid destination,
dnl # throttle the connection by delaying the "550 user unknown" reply
define(`confBAD_RCPT_THROTTLE',`1')dnl
dnl # Sendmail, Chap 24.9.91, Page 1043
dnl # Tune DNS options to work around broken AAAA records (IPv6)
dnl # Not needed if you build sendmail without IPv6 support
define(`confBIND_OPTS',`WorkAroundBrokenAAAA')dnl
dnl # Sendmail, Chap 24.9.13, Page 955
dnl # Force daemon to re-write queue control file after successful delivery
dnl # to 5 recipients; this will minimize duplicates if the daemon is
dnl # interrupted during a delivery
define(`confCHECKPOINTINTERVAL',`5')dnl
dnl # Sendmail, Chap 24.9.21, Page 960
dnl # Instruct daemon to throttle acceptance of new connections if more
dnl # than 5 new connections arrive in 1 second
define(`confCONNECTION_RATE_THROTTLE',`5')dnl
dnl # Sendmail, Chap 24.9.26, Page 967
dnl # Send E-Mail that double-bounces, and is directed to no local
dnl # recipient, to /dev/null
define(`confDEAD_LETTER_DROP',`/dev/null')dnl
dnl # Sendmail, Chap 24.9.32, Page 973
dnl # Set Delivery Mode to "background" ("interactive" used for debugging)
define(`confDELIVERY_MODE',`background')dnl
dnl # Sendmail, Chap 24.9.25, Page 967
dnl # Specify the maximum size, in bytes, of buffered df* files (default is
dnl # 4096 bytes; 0 turns this off and is not recommended)
define(`confDF_BUFFER_SIZE',`16384')dnl
dnl # Sendmail, Chap 24.9.41, Page 993
dnl # Return error messages that bounce (a double-bounce) to User ID
dnl # "nobody" (will eventually be routed to /dev/null)
define(`confDOUBLE_BOUNCE_ADDRESS',`nobody')dnl
dnl # Sendmail, Chap 24.9.60, Page 1011
dnl # Instruct daemon to stop spawning new children when 25 children already
dnl # exist (note that this can enable a DoS attack)
define(`confMAX_DAEMON_CHILDREN',`25')dnl
dnl # Sendmail, Chap 24.9.63, Page 1013
dnl # Limit maximum size, in bytes, of any given E-Mail to 10 MB
dnl # (10485760 bytes) - checked if sender reports and again at end of DATA
define(`confMAX_MESSAGE_SIZE',`10485760')dnl
dnl # Sendmail, Chap 24.9.66, Page 1016
dnl # Set the upper limit on the number of messages that may be processed
dnl # during any single queue run to 100
define(`confMAX_QUEUE_RUN_SIZE',`100')dnl
Sendmail, Chap 24.9.67, Page 1016
dnl # As an anti-SPAM measure, limit the number of recipients per mail
dnl # envelope to 100 (over the limit tells sending host to defer - 5XX - to later
dnl # for just those addresses over the limit)
define(`confMAX_RCPTS_PER_MESSAGE',`100')dnl
dnl # Sendmail, Chap 24.9.19, Page 959
dnl # Turn on connection caching and limit maximum number of simultaneous
dnl # outbound connections kept open to 1; default is 2; this option also
dnl # depends on MCI_CACHE_TIMEOUT (below)
define(`confMCI_CACHE_SIZE',`1')dnl
dnl # Sendmail, Chap 24.9.19, Page 959
dnl # Set time limit on how long a cached outbound connection may be
dnl # kept open to 120 seconds (2 minutes) - see MCI_CACHE_SIZE above
define(`confMCI_CACHE_TIMEOUT',`120s')dnl
dnl # Sendmail, Chap 24.9.72, Page 1022
dnl # Force messages that are not delivered on the first try to wait a
dnl # minimum of 15 minutes before being processed for another delivery
dnl # attempt (keeps the same failed messages from clogging system)
define(`confMIN_QUEUE_AGE',`15m')dnl
dnl # Sendmail, Chap 24.9.75, Page 1024
dnl # Instruct daemon that if an envelope does not have at least one
dnl # "Recipient:" header, then add a "To: undisclosed-recipients;" header
dnl # to the E-Mail (this can legitmately happen if all recipients are BCCd)
define(`confNO_RCPT_ACTION',`add-to-undisclosed')dnl
dnl # Sendmail, Chap 24.9.78, Page 1027
dnl # Define the name and path of the daemon's PID file
define(`confPID_FILE',`/some/path/sendmail-mta.pid')dnl
dnl # Sendmail, Chap 24.9.80, Page 1029
dnl # Privacy/Security settings
dnl # needmailhelo - require sending host to issue HELO/EHLO before conversing
dnl # noexpn - disable name expansion command
dnl # novrfy - disable SMTP Verify command
dnl # noverb - disable SMTP Verbose mode
dnl # authwarnings - enable "X-Authentication-Warning:" headers
dnl # noetrn - disable client ability to force queue run
dnl # restrictmailq - restrict who can view mail queue
dnl # restrictqrun - restrict who can force a queue run
define(`confPRIVACY_FLAGS', `needmailhelo,noexpn,novrfy,noverb,authwarnings,noetrn,restrictmailq,restrictqrun')dnl
dnl # Sendmail, Chap 24.9.93, Page 1045
dnl # Instruct daemon to convert "Return-Receipt-To:" header to a DSN (RFC 3461 and RFC 3464)
dnl # NOTIFY=SUCCESS request (omitted boolean parameter defaults to "true")
define(`confRRT_IMPLIES_DSN')dnl
dnl # Sendmail, Chapter 24.9.107, Page 1057
dnl # Force MTA to queue each message, even for local delivery, and to sync
dnl # to disk before forking (do not use "interactive" with
dnl # "background" delivery mode)
define(`confSAFE_QUEUE',`true')dnl
dnl # Sendmail, Chap 24.9.109.13, Page 1065
dnl # Disable IDENT (RFC 1413) calls/turn off sending user-host verification
define(`confTO_IDENT',`0')dnl
dnl # Sendmail, Chap 24.9.109.18, Page 1066
dnl # Set a timeout of 3 days before a message that has not been
dnl # successfully delivered is returned to the sender as undeliverable
dnl # (default is 5 days)
define(`confTO_QUEUERETURN',`3d')dnl
dnl # Sendmail, Chap 24.9.109.19, Page 1067
dnl # Set a timeout of 6 hours (24 attempts) before a message that has not
dnl # been delivered generates a warning to the sender that it hasn't been
dnl # delivered yet (default is 4 hours)
define(`confTO_QUEUEWARN',`6h')dnl
dnl # Sendmail, Chap 24.9.120, Page 1077
dnl # Specify the maximum size, in bytes, of buffered xf* files (default is
dnl # 4096 bytes; 0 turns this off and is not recommended)
define(`confXF_BUFFER_SIZE',`16384')dnl
################
## Features Section ##
################
dnl # Disable the following features
undefine(`UUCP_RELAY')dnl
undefine(`BITNET_RELAY')dnl
undefine(`DECNET_RELAY')dnl
undefine(`FAX_RELAY')dnl
dnl # Sendmail, Chap 7.5, Page 311
dnl # Turn on Access DB to accept/reject mail from selected sites, and
dnl # specify database type, path and name; "-o" makes it optional and
dnl # "-T<TMPF>" parameter instructs daemon to return SMTP 4xy codes
dnl # for temporary errors
FEATURE(`access_db',`dbm -o -T<TMPF> /etc/mail/access')dnl
dnl # Sendmail, Chap 7.5.5, Page 317
dnl # Allow blacklisting to be done on a per-recipient basis
FEATURE(blacklist_recipients)dnl
dnl # Sendmail, Chap 7.5.6, Page 318
dnl # Change order of relay checks (requires "access_db" feature above)
dnl # to check SMTP RCPT TO: first, then SMTP MAIL FROM:, and finally
dnl # the host (via access_db and RBLs) - "friend" keyword allows
dnl # entries in access_db to override RBLs and "n" turns off
dnl # backwards-compatibility with earlier versions of sendmail
dnl # This allows creation of specific entries in the access database
dnl # that bypass the RBLs (for example, an "abuse" alias, or the
dnl # address in the custom reject messages below)
FEATURE(`delay_checks',`friend',`n')dnl
dnl # Sendmail, Chap 7.2.1, Page 296
dnl # RBL lookup failures will be treated as not blacklisted (i.e. setting
dnl # is to "fail friendly")
dnl # Activate default DNS blacklist (mail-abuse.org)
FEATURE(dnsbl)dnl
dnl # Sendmail, Chap 7.2.2, Page 297
dnl # Add SpamHaus BL with custom reject message
FEATURE(`enhdnsbl',`sbl.spamhaus.org',`"ACCESS DENIED. Mail from " $&{client_addr} " refused based on information from http://www.spamhaus.org/SBL"')dnl
dnl # Sendmail, Chap 7.2.2, Page 297
dnl # Add ORDB BL with custom reject message
FEATURE(`enhdnsbl',`relays.ordb.org',`"ACCESS DENIED. Mail from " $&{client_addr} " refused based on information from http://www.ordb.org"')dnl
dnl # Sendmail, Chap 7.2.2, Page 297
dnl # Added NJABL BL with custom reject message
FEATURE(`enhdnsbl',`dnsbl.njabl.org',`"ACCESS DENIED. Mail from " $&{client_addr} " refused based on information from http://njabl.org"')dnl
dnl # Sendmail, Chap 7.2.2, Page 297
dnl # Add AbuseAt BL with custom reject message
FEATURE(`enhdnsbl',`cbl.abuseat.org',`"ACCESS DENIED. Mail from " $&{client_addr} " refused based on information from http://cbl.abuseat.org"')dnl
dnl # Sendmail, Chap 7.2.2, Page 297
dnl # Add SpamCop BL with custom reject message
FEATURE(`enhdnsbl',`bl.spamcop.net',`"ACCESS DENIED. Mail from " $&{client_addr} " refused based on information from http://spamcop.net/bl.shtml?"$&{client_addr}')dnl
dnl # Sendmail, Chap 4.8.16, Page 181
dnl # Turn on Generics mapping and specify database type, path and
dnl # name; "-o" makes it optional (used for re-writing FROM of outgoing
dnl # mail)
FEATURE(`genericstable',`dbm -o /etc/mail/genericstable')dnl
dnl # Sendmail, Chap 4.8.24, Page 188
dnl # Turn on per-Domain message delivery agent selection and specify
dnl # database type, path and name; "-o" makes it optional
FEATURE(`mailertable',`dbm -o /etc/mail/mailertable')dnl
dnl # Sendmail, Chap 4.8.28, Page 192
dnl # Turn off E-Mail canonization (should be done by MSA, and this
dnl # is a mail relay with no local users)
FEATURE(`nocanonify')dnl
dnl # Sendmail, Chap 4.8.30, Page 194
dnl # Instruct daemon not to listen on port 587 for local MSA (this
dnl # is a mail relay with no local users submitting mail)
FEATURE(`no_default_msa')dnl
dnl # Sendmail, Chap 4.8.32, Page 194
dnl # Turn off all UUCP support and give reject message
FEATURE(`nouucp', reject)dnl
dnl # Sendmail, Chap 4.8.47, Page 199
dnl # Enable use of Trusted User's file
dnl # Default location is /etc/mail/trusted-users
dnl # File is required by default; see Page 199
FEATURE(`use_ct_file')dnl
dnl # Sendmail, Chap 4.8.51, Page 201
dnl # Turn on Virtual User mapping and specify database type, path and
dnl # name; "-o" makes it optional
FEATURE(`virtusertable',`dbm -o /etc/mail/virtusertable')dnl
################
## Macro Definitions ##
################
dnl # Sendmail, Chap 21.9.100, Page 834
dnl # Set the config file version in format <server>-<serial #>
define(`confCF_VERSION',`host-123')dnl
dnl # Sendmail, Chap 7.5.4, Page 317
dnl # Set a custom message for connection rejections based on access DB
define(`confREJECT_MSG',`550 Your mail has been rejected. Report problems to bugger.off@somedomain.tld')dnl
dnl # Sendmail, Chap 7.4.2, Page 304
dnl # Set a custom message for relay attempts by unauthorized hosts
define(`confRELAY_MSG',`550 Relay DENIED: report problems to bugger.off@somedomain.tld')dnl
dnl # Sendmail, Chap 4.8.16.2, Page 183
dnl # Define the name and path of the Generic Domains file; "-o" makes
dnl # its existence optional; used in conjunction with genericstable feature
GENERICS_DOMAIN_FILE(`-o /etc/mail/generic-domains')dnl
##########
## Mailers ##
##########
dnl # Per Sendmail book (Chapter 4.2.2.2, page 152) do not change order
dnl # "local" removed since this is a relay host with no local accounts
dnl # NOTE: Removing the "MAILER(local)" entry isn't strictly kosher, so
dnl # depending on your comfort level, you may wish to keep it; if
dnl # you do keep it, make it the LAST entry in the list of MAILER entries
MAILER(smtp)dnl
##################
## Local Config Section ##
##################
dnl # Any local configuration statements, such as local
dnl # macro definitions, should go here.
dnl # Define a file for the Domains that are Virtually Hosted - but
dnl # do NOT use the built-in VIRTUSER_DOMAIN_FILE macro, as that also
dnl # adds the Domains to RELAY_DOMAINS ("Class {R}"), resulting in bypass
dnl # of the RBLs and the virtusertable lookups
dnl # Credit to Jan Pieter Cornet for this idea
LOCAL_CONFIG
F{VirtHost}/etc/mail/virtuser.domains
##################
## Local Rules Section ##
##################
dnl # Per Sendmail book (Chapter 4.2.2.2, page 153) the LOCAL_RULES
dnl # need to go AFTER the Mailers
dnl # See Sendmail book pages 158, 159 and Chapters 19 and 25
dnl # Define special rules for this host to use when processing mail
dnl # IMPORTANT NOTES: Ruleset names should begin with capital
dnl # letter to avoid collision with sendmail internal
dnl # rulesets; TAB is the delimiter between key entries,
dnl # spaces will NOT work
##################
## End of sendmail.mc ##
##################
##################################
# Author: A-NAME-HERE
# File: /etc/mail/access
# Change Log:
# Who When What
# ---- ----------- --------------------------------------------
#
#
# NOTE: delay_checks MUST be enabled in sendmail.mc
# so that checks are performed in correct order
# See Sendmail book, Chap 7.5.6, Page 318
# An RBLed sender can ONLY bypass the RBL if
# the action-word FRIEND can be associated with
# their mail; therefore, the RELAY directives
# for the hosted Domains do not bypass the RBLs
#
# DSN codes for ERROR values are on page 708.
#
# Syntax:
# (Optional) Header or keyword, and value, to match [whitespace] Action keyword
# Permit relay (bypass RBL) for internal hosts that relay thru this one
# No sense in doing RBL lookups for our own hosts
Connect:10.1.2.3 RELAY
Connect:10.4.5.6 RELAY
Connect:10.7.8.9 RELAY
# Permit E-Mail TO access.denied to get thru, even if sendmail thinks
# that the sender is a spammer; this allows legit senders who've been
# RBLed to request white-listing (altho they also need to get themselves
# off of whichever RBL they are on)
Spam:bugger.off@somedomain.tld FRIEND
# Reject/Discard annoying specific addresses
# Note 1: This syntax discards it in EITHER direction
# Note 2: While the syntax shown is still technically valid, a leadin
# "To:" or "From:" tag is expected by newer sendmail versions
# (as shown in the example several lines down)
really.annoying@really.annoying.domain DISCARD
# To discard based on From: or To:, prepend the appropriate string, like so
To:easily.annoyed@somedomain.tld DISCARD
From:annoying.person@aol.com DISCARD
# To reject with a failure message instead of silently dropping,
# change DISCARD to REJECT; sendmail will use default reject
# message or custom one defined in sendmail.mc (as above)
From:luser@msn.com REJECT
# Reject for users no longer here but they keep getting SPAM
To:retired.threeyearsago@somedomain.tld ERROR:5.1.7:550 SPAM rejected
# Relay for hosted Domains
To:somedomain.tld RELAY
To:otherdomain.tld RELAY
To:hosteddomain.tld RELAY
####################
## End of /etc/mail/access ##
####################
##################################
# Author: A-NAME-HERE
# File: /etc/mail/aliases
# Change Log:
# Who When What
# ---- ----------- --------------------------------------------
#
#
# Syntax:
# keyword to match: value to substitute
# Following alias is required by the mail protocol, RFC 822
# Set it to the address of a HUMAN who deals with this system's mail problems.
Postmaster: root@someinteriorhost.somedomain.tld
# Alias for mailer daemon; returned messages from our MAILER-DAEMON
# should be routed to our local Postmaster
MAILER-DAEMON: postmaster
# And finally, an alias to direct dead E-Mail to the bit-bucket
nobody: /dev/null
####################
## End of /etc/mail/aliases ##
####################
##################################
# Author: A-NAME-HERE
# File: /etc/mail/domaintable
# Change Log:
# Who When What
# ---- ----------- --------------------------------------------
#
#
# Syntax:
# keyword to match: value to substitute
#
#
# Provides mapping of Domain Names - from old to new
# See Sendmail, Chap 4.8.13, Page 180
# Generally should not be needed - virtusertable
# is preferred. Only use when actually migrating a Domain
########################
## End of /etc/mail/domaintable ##
########################
##################################
# Author: A-NAME-HERE
# File: /etc/mail/genericstable
# Change Log:
# Who When What
# ---- ----------- --------------------------------------------
#
#
# Syntax:
# keyword to match [whitespace] value to substitute
#
# Sendmail generic name rewrite file - See Sendmail, Chap 4.8.16, Page 181
#####################
## Outgoing FROM: rewrites ##
#####################
# Re-write "luser@somedomain.tld" as "mr.smith@somedomain.tld"
luser@somedomain.tld mr.smith@somedomain.tld
# Re-write "bob@somedomain.tld1" as "george@hosteddomain.tld2"
bob@somedomain.tld1 george@hosteddomain.tld2
########################
## End of /etc/mail/genericstable ##
########################
##################################
# Author: A-NAME-HERE
# File: /etc/mail/mailertable
# Change Log:
# Who When What
# ---- ----------- --------------------------------------------
#
#
#
# Syntax:
# keyword to match [whitespace] mailer:host to use
#
# Maps Domain Names to delivery agents and host for routing
# See Sendmail, Chap 4.8.24, Page 188
# Direct incoming mail to appropriate internal hosts (and don't use MX lookups)
hostX.somedomain.tld smtp:[hostx.somedomain.tld]
somedomain.tld smtp:[userbox.somedomain.tld]
hosteddomain.tld smtp:[hostserver.somedomain.tld]
# Route incoming E-Mail to a host we don't have in DNS at all yet
brandnewdomain.tld smtp:[10.2.3.4]
# If anything arrives for this Domain we no longer host, send
# it to its new location (and look up that location)
nothostedanymoredomain.tld smtp:serverx.otherplace.tld
#####################
# End of /etc/mail/mailertable #
#####################
##################################
# Author: A-NAME-HERE
# File: /etc/mail/virtusertable
# Change Log:
# Who When What
# ---- ----------- --------------------------------------------
#
#
#
#
#
# Syntax:
# Address or Domain name to match [whitespace] New address specification
#
# Virtual user mapping database for INbound E-Mail
# See Sendmail, Chap 4.8.51, Page 201
#
# Allows on-the-fly re-routing of mail, but does NOT
# change headers.
#
# This is consulted AFTER aliases and BEFORE mailertable
# Send E-mail to specific host/address
bob@anotherdomain.tld bobz@hostbob.otherdomain.tld
# Send E-mail to a different hosted Domain (mailertable will route)
phil@otherdomain.tld phil@somedomain.tld
# Direct E-Mail to a "fake" address to a "real" person
bugger.off@somdomain.tld postmaster@itstaffserver.somedomain.tld
# Send all E-mail for a Domain to the same address at a specific host
@hosteddomain.tld %1@userbox.somedomain.tld
# Reject all E-Mail to a Domain that's no longer hosted
@nothereanymore.tld error:nouser 550 No such user here
########################
## End of /etc/mail/virtusertable ##
########################
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)