1. Skip to Menu
  2. Skip to Content
  3. Skip to Footer>
Sunday Apr 28th     7:45 AM PDT                                  

Configuring Sendmail Part 1

PDF Print E-mail

Written by Greg King Friday, 27 November 2009 14:23

Sendmail is a trademark of Sendmail, Inc. and is an open source email server.  It is normally pretty complicated to install, and the documentation seems to be written by experts and generally confuses the novice system administrator.  In this section, we will walk you through installing and configuring it.  More information can be found by visiting the sendmail website.  Sendmail comes pre-installed in FreeBSD, so we don't need to specifically install it.  We do need to install some helper applications and configure sendmail for proper operations.


Getting Started


Copy over and edit the make.conf file so sendmail will use sendmail.mc & submit.mc to build the .cf macros.

# cd /etc/
# cp -p /usr/share/examples/etc/make.conf /etc/make.conf
# nano make.conf


Uncomment and edit the following lines as follows:

SENDMAIL_MC=/etc/mail/sendmail.mc
SENDMAIL_SUBMIT_MC=/etc/mail/submit.mc

# cd /etc/mail


 Configure Local Domains


# cat << EOF > /etc/mail/local-host-names

put the domain names your server will host mail for into the file, one per line, then put EOF at the end.  Example:

mydomain1.com
mydomain2.com
mydomain3.com
EOF

Configure Trusted Users


# cat << EOF > /etc/mail/trusted-users

www
EOF

 Configuring access file


Sendmail's access file specifies who can access the server for things like relaying.  Relaying is when a server accepts email from someone and relays it to a a mail server that is not local to the system.  You obviously don't want to relay for everyone because spammers will soon discover your server and take advantage of your generosity (and bandwith) to send spam.  To prevent this, we are going to specify who can relay.  Keep in mind, these are systems, not users.  "mydomain.com" and the ip "xxx.xxx.xxx.xxx" should be modified to use your domain and the ip of your server. Unless the system is listed here, or the destination is listed in the local-host-names file, the mail will be rejected and no further action will take place.

# cp -p /etc/mail/access.sample /etc/mail/access
# nano access

localhost.localdomain	RELAY
localhost RELAY
127.0.0.1 RELAY
xxx.xxx.xxx.xxx (your server IP) RELAY
mydomain.com RELAY

 Configuring virtual users table


Virtual users are not necessarily needed.  This just lets you map an email address to an account on the local machine.  It is primarily used to keep hackers from knowing account names on your server.  For instance, if my login username is "admin" and my email address is This e-mail address is being protected from spambots. You need JavaScript enabled to view it , I could send all mail addressed to This e-mail address is being protected from spambots. You need JavaScript enabled to view it to the user account of admin.

# cp -p /etc/mail/virtusertable.sample /etc/mail/virtusertable
# nano virtusertable

  This e-mail address is being protected from spambots. You need JavaScript enabled to view it
 		admin

 Create Sendmail.mc file


Create the semdmail.mc file which will be compiled into the sendmail.cf configuration file.

***NOTE: Be careful with the "word wrap" of lines in the file below.  Turn OFF Word Wrap.***

***NOTE2: You will need to edit the 'DAEMON_OPTIONS(`Port=smtp,Addr=...' line to fit your system***
 
# cat > /etc/mail/sendmail.mc
paste the following into the prompt.  At the end, hit control-d key (CTRL-D).
 
divert(-1)
#
# Copyright (c) 1983 Eric P. Allman
# Copyright (c) 1988, 1993
#       The Regents of the University of California.  All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#       This product includes software developed by the University of
#       California, Berkeley and its contributors.
# 4. Neither the name of the University nor the names of its contributors
#    may be used to endorse or promote products derived from this software
#    without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
#  This is a generic configuration file for FreeBSD 4.X and later systems.
#  If you want to customize it, copy it to a name appropriate for your
#  environment and do the modifications there.
#
#  The best documentation for this .mc file is:
#  /usr/share/sendmail/cf/README or
#  /usr/src/contrib/sendmail/cf/README
#
divert(0)
VERSIONID(`$FreeBSD: src/etc/sendmail/freebsd.mc,v 1.10.2.18 2003/04/24 16:57:30 gshapiro Exp $')dnl
OSTYPE(freebsd4)dnl
DOMAIN(generic)dnl
dnl
define(`PROCMAIL_MAILER_PATH', `/usr/local/bin/procmail')dnl
define(`confCW_FILE', `/etc/mail/local-host-names')dnl
dnl
FEATURE(`access_db', `hash -o -T<TMPF> /etc/mail/access')dnl
FEATURE(`genericstable', `hash -o /etc/mail/genericstable')dnl
FEATURE(`mailertable', `hash -o /etc/mail/mailertable')dnl
FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable')dnl
FEATURE(`use_cw_file')dnl
dnl
FEATURE(`blacklist_recipients')dnl
dnl FEATURE(`local_lmtp')dnl
FEATURE(`local_procmail',`',`procmail -t -Y -a $h -d $u')dnl
FEATURE(`delay_checks')dnl
dnl
FEATURE(`dnsbl')dnl
FEATURE(`dnsbl', `relays.ordb.org', `Rejected - see http://ordb.org/')dnl
FEATURE(`dnsbl', `relays.visi.com', `Rejected - see http://relays.visi.com/')dnl
FEATURE(`dnsbl', `sbl-xbl.spamhaus.org', `Rejected - see http://www.spamhaus.org/lookup.lasso')dnl
FEATURE(`dnsbl', `list.dsbl.org', `Rejected - see http://www.dsbl.org/')dnl
FEATURE(`dnsbl', `bl.spamcop.net', `"Spam blocked see: http://spamcop.net/bl.shtml?"$&{client_addr}')dnl
FEATURE(`dnsbl',`dnsbl.sorbs.net',`"554 Rejected " $&{client_addr} " found in dnsbl.sorbs.net"')dnl
FEATURE(`dnsbl', `cbl.abuseat.org', `Rejected - see http://cbl.abuseat.org/')dnl
dnl
FEATURE(`relay_entire_domain')dnl
EXPOSED_USER(`root')dnl
dnl
dnl This changes sendmail to only listen on the loopback device 127.0.0.1
dnl and not on any other network devices. Comment this out if you want
dnl to accept email over the network.
DAEMON_OPTIONS(`Port=smtp,Addr=xxx.xxx.xxx.xxx, Name=MTA')dnl
dnl
dnl Uncomment both of the following lines to listen on IPv6 as well as IPv4
DAEMON_OPTIONS(`Name=IPv4, Family=inet')dnl
DAEMON_OPTIONS(`Name=IPv6, Family=inet6')dnl
dnl
define(`confBIND_OPTS', `WorkAroundBrokenAAAA')dnl
define(`confNO_RCPT_ACTION', `add-to-undisclosed')dnl
define(`confPRIVACY_FLAGS', `authwarnings,noexpn,novrfy')dnl
dnl
dnl Cwlocalhost.localdomain
dnl
dnl MAILER(local)dnl
MAILER(smtp)dnl
MAILER(procmail)dnl

Remember to hit CTRL-D to save the file.

We are ending the article at this point because the next step involves a significant copy/paste as well and we don't want to confuse the two.  We will see you in part 2!

  Configuring an E-Mal Server
eXTReMe Tracker
Content View Hits : 404665