Sunday, September 13, 2009

SENDMAIL Notes 1 - Installing Sendmail from Source Code

Topics
Compiling Installing and Testing Sendmail


1. Download sendmail & GPG Key

#wget ftp://ftp.sendmail.org/pub/sendmail/sendmail.8.14.2.tar.gz
#wget ftp://ftp.sendmail.org/pub/sendmail/sendmail.8.14.2.tar.gz.sig


2. Download the GPG key and check the integrity of the file

Check md5sum
#md5sum ssendmail.8.14.2.tar.gz
#md5sum ssendmail.8.14.2.tar.gz.sig

compare with md5sum in the website for both packages 

GPG Key Check
#gpg --import sendmail_gpgkeys
#gpg --verify sendmail.8.14.2.tar.gz.sig sendmail.8.14.2.tar.gz


3. Install sendmail

Step1:

Extract the downloaded archieve

# tar -zxvf sendmail.8.14.2.tar.gz
# cd sendmail-8.14.2
#ls

    Lists the folders inside the source code below are some important Folders inside the source code:
cf:
   contains sample config files ideal for enviornment
contrib:
   contains the source code provided by third party
doc:
    documentations
libmilter:
   plugins for clamav, spamassassin etc
makemap:
   makemap utility for the configurations
mailstats:

sendmail:
   contains the sourcefiles with the Bulid exicutable which uses for installation

Step2:


Bulding the source code
#cd sendmail-8.14/sendmail
#./Build
#cd ../obj.Linux.2.6.18-128.el5.i686/


  This directory contains all the binaries & object files

Step3:
 Now go to other directories Build & install the binaries & configurations

# cd ../cf/cf

  Here we can find the platform specific configuration files of sendmail, each *.mc file contains corresponding *.cf file
so check for generic-linux.mc and copy to sendmail.mc file to create the configuration file. sendmail.cf file is used by sendmail while running as a MTA (mail Transmission Agent)
We need the submit.mc file as well. this file is used by sendmail while running as Mail Submission Program (MSP)
submit.mc is used while local mail submition to sendmail queue

# cp generic-linux.mc sendmail.mc
#ls

   now we have both mc files submit.mc & sendmail.mc file in place

# ./Build install-cf

 (install-cf Installs the configuration files) This will run the m4 process which will export the submit.mc & sendmial.mc to /etc/mail by creating the *.cf file

# ls /etc/mail

check the /etc/mail directory folders for the sendmail.cf and submit.cf file

Step4:


Now add the user&group so that a portion of sendmail can be run without the root privilage,the sendmail daemon runs with root privilages so this step is needed to avoid the security issue

#useradd smmsp
#groups smmsp


Step5:

Now install the main binary files

#cd sendmail-8.14.2/sendmail
#./Build install
#ls -al /usr/sbin/sendmail


Step6:

Now go to directory makemap and build and install the makemap utility
#cd ../makemap
#./Build
#./Build install


Step7:

Now go to mailstats directory - Build & install mailstats
# cd ../mailstats/
# ./Build && ./Build install


Post Installation Chores:

Check the sendmail configurations and files are correct


# sendmail -v -bi
   this will show the errors in configurations, permission problems, alias problems etc.

In my case it given error for /etc/mail/local-host-names & /var/spool/mqueue/
so we need to define the file /etc/mail/local-host-names
 

Note:

When sendmail receives mail, it needs a way of determining whether it is responsible for the mail it receives. It uses the /etc/mail/local-host-names file to do this. This file has a list of hostnames and domains for which sendmail accepts responsibility. For example, if this mail server was to accept mail for the domains my-site.com and another-site then the file would look like this:
-------
my-site.com
another-site.com
-------


Create the local-host-name file

 
#echo "localhost" > /etc/mail/local-host-names

When Sendmail functions as MTA it stores file in /var/spool/mqueue/ directory.So this directory is very much in need.


in MTA: If the mail delivery is not happening with respect to any config issues or unavailability of the mail destination the mails are stored in /var/spool/mqueue/ directory
in MSP: if mail delivery is not happening it stores mail in clientmqueue directory

#mkdir /var/spool/mqueue/
#chmod 700 /var/spool/mqueue/

#chown smmsp:smmsp /var/spool/clientmqueue
#chmod 770 /var/spool/clientmqueue



Now again run the sendmail checking utility
#sendmail -v -bi

 
If can see the /etc/mail/aliases file is missing, go to sendmail source code directory and copy the aliases file to /etc/mail and generate the db file of aliases

#cd sendmail.8.14/sendmail
# cp aliases /etc/mail/
#newaliases

 
    if the db converting tools (db4 & db4-devel) are not installed before the sendmail compilation we have to install the db tools which is required for aliases databases creation, then recompile the sendmail source code to include the utility.

Now again run the sendmail checking utility
#sendmail -v -bi


Now this gives the tottal number of aliases in the aliases file. This means that we have installed the sendmail packages correctly.
 

Man page error while compiling
Because the sendmail assumes that the man page directory as /usr/man and normal linux systems uses /usr/share/man
so creating a soft link of /usr/share/man to /usr will solve this issue
#ln -s /usr/share/man /usr

 

So using the same method we can install all the binaries available with in the sendmail sorce-code to get a full fledged sendmail server.
Note:-
     The /etc/hosts file should be updated properly to work sendmail smoothly. 

No comments:

Post a Comment

tag ur valuable ideas below