1. Skip to Menu
  2. Skip to Content
  3. Skip to Footer>
Saturday Apr 27th     9:53 PM PDT                                  

Configuring Sendmail Part 2

PDF Print E-mail

Written by Greg King Friday, 27 November 2009 15:43

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.

This is part two of the configuration.  If you have not followed part one, you need to do so.


 Create submit.mc file



Next, create the sendmail.submit.mc file which will be compiled into the sendmail.submit.cf file.


NOTE: Be careful with the "word wrap" of lines in the above file.  Turn off Word Wrap.

# cat > /etc/mail/submit.mc

copy and paste the following into the prompt.  Hit CTRL-D when done.

divert(-1)
#
# Copyright (c) 2001, 2002 Sendmail, Inc. and its suppliers.
#       All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#
#
#  This is the prototype file for a set-group-ID sm-msp sendmail that
#  acts as a initial mail submission program.
#
divert(0)dnl
VERSIONID(`$Id: submit.mc,v 8.6.2.4 2002/12/29 03:54:34 ca Exp $')
define(`confCF_VERSION', `Submit')dnl
define(`__OSTYPE__',`')dnl dirty hack to keep proto.m4 from complaining
define(`_USE_DECNET_SYNTAX_', `1')dnl support DECnet
define(`confTIME_ZONE', `USE_TZ')dnl
define(`confDONT_INIT_GROUPS', `True')dnl
define(`confCT_FILE', `/etc/mail/trusted-users')dnl
FEATURE(`use_ct_file')dnl
dnl
dnl If you use IPv6 only, change [127.0.0.1] to [IPv6:::1]
FEATURE(`msp', `[127.0.0.1]')dnl

Don't forget to hit CTRL-D to save the file.


 Finishing Up


Consider editing the alises file.  Pretty much everything else in this file points to "root", so you would do well in either reading root's mailbox or forwarding root's email from here. Daily Log Run Output is a good example of root's email that you need to see.  Add an entry to the aliases file specifying root:your_email_address as shown below.

# nano aliases

root:<tab> This e-mail address is being protected from spambots. You need JavaScript enabled to view it   

and save.

Now we build our changes.

# make all

Now, we are ready to restart Sendmail and check the log file to make sure it is running without errors.
 
# make restart
# tail -f /var/log/maillog

Confirm that sendmail is enabled in the /etc/rc.conf file, if not, add it:

# nano /etc/rc.conf

sendmail_enable="YES"
Make sure that the smtp port 25 is open and accepting connections by telneting to your system on port 25 (the default port for mail).  In the example below, the ip of the system is 192.168.1.1:

# telnet 192.168.1.1 25

You should get a connection.  If you get connection refused, restart your server with # restart -r now  and try it again.  If it still doesn't work, look at the log file for errors.  The most common errors would be in the sendmail.mc or submit.mc files, so check those carefully looking for evidence of word wrap in your paste (hint, most lines end with a dn1)


 Reading Sendmail log files


Sendmail stores old log files in bzip2 format.  In order to read these archived logs, use the 'bzcat' command to decompress the file to standard output.  More options are in 'man bzip2'. 

# cd /var/log
# bzcat bzcat maillog.0.bz2

 

Ok, so now we have a properly running sendmail system.  By default, Sendmail will put user's mail in their home directory under a .mail subdir (/home/<user>/.mail .  This is not always ideal, as it requires a local account for each email recipient and does not work well if you host more than one domain.  

In the next section, we will explore using maildir format which allows for virtual users.

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