MikeDittmeier/Drafts/SendmailGuide

= Sendmail Guide =

[[TableOfContents(3)]

Introduction
This document will walk you through the process of setting up an SMTP server or MTA (Mail Transfer Agent) for relaying email. We'll start off by allowing connections from other computers and then work our way through securing email transmissions as well as scanning emails for viruses and even SPAM. Some of the other features covered in this document are distribution lists, and even redirecting incoming emails to other domains. The section for Sendmail basic configuration will get us started, but each following section can be used by itself or combined with other sections to add more customization and functionality to your system.

Audience
This document is designed for IT and system administrators.

Requirements

 * Installed OS
 * Configured TCP/IP
 * Configured DNS
 * Added Users and Groups
 * Configure IPTables and Firewalls
 * Active internet connection
 * Basic understanding of vi and bash commands

Package Requirements
This article makes use of the following packages found in the Fedora Repository:


 * sendmail
 * sendmail-cf
 * sendmail-doc
 * spamassassin
 * spamass-milter
 * clamav
 * clamav-data
 * clamav-libs
 * clamav-server
 * clamav-update
 * clamav-filesystem
 * clamav-milter

Installing Sendmail
By default sendmail is already included in most fedora installation. To verify sendmail is installed by typing the following command:

rpm -q sendmail

this should output the follow results:

sendmail-8.14.1-4.2.fc7

if not, lets install the sendmail packages by typing:

yum install -y sendmail sendmail-cf sendmail-doc

Configuring Sendmail
Sendmail has several configuration files located in the /etc/mail folder. Below is a list of the mos common files:


 * /etc/mail/access, host access file
 * /etc/mail/domaintable, list of domains for the mail server
 * /etc/mail/local-host-names, list of hostnames this server is seen as
 * /etc/mail/mailertable, table of domains and how to route the email sent to those domains
 * /etc/mail/trusted-users, list of users that can send mail on behalf of other users
 * /etc/mail/virtusertable, list of users and domains and who to forward email to
 * /etc/mail/sendmail.mc, main sendmail configuration file
 * /etc/mail/submit.mc, mail submission settings
 * /etc/aliases, user aliases

Allowing External Connections
By default sendmail will only accept incoming connections from the localhost or 127.0.0.1 host. the first change we will make to our sendmail.mc file will be to allow connections from other hosts. First we will need to make a backup of the default sendmail.mc file in case we need to roll back. Open a shell and enter the following command:

cp /etc/mail/sendmail.mc /etc/mail/sendmail.mc.bak

Now we are going to begin editing the sendmail.mc. at a shell prompt enter the following command:

vim /etc/mail/sendmail.mc

The sendmail configuration file should now be displayed in the vi editor window. Now we are going to search for the line of text that will allow us to modify what hosts sendmail will accept connection from. In the vi editor press the "esc" key, then type

/Port=smtp

this should take you to the following line in the sendmail.mc:

DAEMON_OPTIONS( Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

There is two different ways to modify this line. we can comment out the line by adding "dnl" to the beginning of the line, or by changing the ipaddress to the same ip as the server. for simplicity reasons we will just comment out the line. make sure your cursor is at the begining of the line and pres the "esc" key and then the "i" key to begin inserting text. add "dnl" to the begining of the line. your line should now look like this:

dnl DAEMON_OPTIONS( Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

Save the file chnages by pressing the "esc" key and typing:


 * wq

To make sendmail start using these settings, we will first apply the changes, and then restart the sendmail daemon. from a shell prompt, type the command:

make -C /etc/mail

You should see output similar to the text below:

make: Entering directory /etc/mail' make: Leaving directory /etc/mail'

Next we need to restart the sendmail daemon by typing the following text at a shell prompt:

service sendmail restart

Your changes are now in effect and sendmail will allow connections from any ip.

Auto Starting Sendmail
Now that sendmail is configured to allow connections from other hosts, we need to make sure the daemon starts after system reboots. To acomplish this, simple enter the following command at a shell prompt:

chkconfig sendmail 345 on

This tells the daemon to start when in run levels 3, 4, and 5.

to verify that the settings have taken place, we can use the chkconfig, and grep commands. Enter the following command at the shell prompt:

chkconfig --list | grep sendmail

You should see the following output:

sendmail       0:off   1:off   2:on    3:on    4:on    5:on    6:off

You will notice the run level 3, 4, and 5 are listed as on. This means the daemon will start automatically in our desired run levels.