sendmail
Managing who you will relay mail for is important, as it is another technique commonly employed by spamming hosts to circumvent systems such as the Real-time Blackhole List just described. Instead of sending the mail to you directly, spammers will relay the mail via some other unsuspecting host who allows it. The incoming SMTP connection then doesn't come from the known spamming host, it instead comes from the relay host. To ensure that your own mail hosts aren't used in this way, you should relay mail only for known hosts. Versions of sendmail that are 8.9.0 or newer have relaying disabled by default, so for those you'll need to use the access database to enable individual hosts to relay.
The general idea is simple. When a new incoming SMTP connection is received, sendmail retrieves the message header information and then consults the access database to see whether it should proceed to accept the body of the message itself.
The access database is a collection of rules that describe what action should be taken for messages received from nominated hosts. The default access control file is called
OK
Accept the mail message.
RELAY
Accept messages from this host or user even if they are not destined for our host; that is, accept messages for relaying to other hosts from this host.
REJECT
Reject the mail with a generic message.
DISCARD
Discard the message using the $#discard mailer.
### any text
Return an error message using
An example
[email protected] REJECT
aol.com REJECT
207.46.131.30 REJECT
linux.org.au RELAY
This example would reject any email received from
To enable the access database feature, use the following declaration in your
FEATURE(access_db)
The default definition builds the database using hash -o /etc/mail/access, which generates a simple hashed database from the plain text file. This is perfectly adequate in most installations. There are other options that you should consider if you intend to have a large access database. Consult the
Barring users from receiving mail
If you have users or automated processes that send mail but will never need to receive it, it is sometimes useful to refuse to accept mail destined for them. This saves wasted disk-space storing mail that will never be read. The
To enable the feature, you add the following lines to your
FEATURE(access_db)
FEATURE(blacklist_recipients)
To disable receipt of mail for a local user, simply add his details into the access database. Usually you would use the
daemon 550 Daemon does not accept or read mail.
flacco 550 Mail for this user has been administratively disabled.
[email protected] 550 Mail disabled for this recipient.
Configuring Virtual Email Hosting
Virtual email hosting provides a host the capability of accepting and delivering mail on behalf of a number of different domains as though it were a number of separate mail hosts. Most commonly, virtual hosting is exploited by Internet Application Providers in combination with virtual web hosting, but it's simple to configure and you never know when you might be in a position to virtual host a mailing list for your favorite Linux project, so we'll describe it here.
Accepting mail for other domains
When sendmail receives an email message, it compares the destination host in the message headers to the local host name. If they match, sendmail accepts the message for local delivery; if they differ, sendmail may decide to accept the message and attempt to forward it on to the final destination (See 'The access database' earlier in this chapter for details on how to configure sendmail to accept mail for forwarding).
If we wish to configure virtual email hosting, the first thing we need to do is to convince sendmail that it should also accept mail for the domains that we are hosting. Fortunately, this is a very simple thing to do.
The sendmail
FEATURE(use_cw_file)
The default name of the file will be