Sunday, September 13, 2009

SENDMAIL Notes 1 - Installing Sendmail from Source Code

Compiling Installing and Testing Sendmail

1. Download sendmail & GPG Key


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


Extract the downloaded archieve

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

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

   contains the sourcefiles with the Bulid exicutable which uses for installation


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

  This directory contains all the binaries & object files

 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 and copy to file to create the configuration file. file is used by sendmail while running as a MTA (mail Transmission Agent)
We need the file as well. this file is used by sendmail while running as Mail Submission Program (MSP) is used while local mail submition to sendmail queue

# cp

   now we have both mc files & file in place

# ./Build install-cf

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

# ls /etc/mail

check the /etc/mail directory folders for the and file


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


Now install the main binary files

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


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


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


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 and another-site then the file would look like this:

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/

    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.
     The /etc/hosts file should be updated properly to work sendmail smoothly. 

No comments:

Post a Comment

tag ur valuable ideas below