SMARTHOST CONFIGURATION USING SENDMAIL + CYRUS - SASL

I am having a mail server islbom2.utiisl.co.in. I have another server at a remote site which is running sendmail. My registered domain is utiisl.co.in. 
My intention is to create a mail server for the people connected to the remote server so that they can connect to islbom2 and relay mails to the outside world. Local mails need to be delivered in the local server without any delay. While mails for the outside world may be delivered  to islbom2 server for relaying it to the Internet.The remote server has been named gsd.utiisl.co.in so that any mail being send from there has the sender's name as user@gsd.utiisl.co.in
I would give the specifications related to the  installation of the remote server first. 
My remote server is running on RedHat Linux 7.2. I was not very sure about with what all settings sendmail was configured. So I removed the rpm altogether with --nodeps option and then did the following::

  1. Install sendmail from the rpm. I took the sendmail and sendmail-cf rpm from the RedHat Linux CD. In case you cannot find it download it from ftp.redhat.com/os/i386/RedHat/RPMS/
  2. Install sendmail using command # rpm -i sendmail-8.128-4  and # rpm -i  sendmail-cf-8.12.8-4.
  3. Then Edit the sendmail.mc file to add features of generics, dgenerics, authinfo and smarthost. An example file of sendmail.mc is available here.
  4. In /etc/mail create files genericsdomain, genericstable, dgenericstable, authinfo.txt, service.switch. 
  5. After the creation of the files create a db of the above files using the command : # makemap -r  hash access   <  access. Similarly this has to be done for genericstable, dgenericstable. 

Files : genericsdomain :  This should contain the name of the server  as found from the HOSTNAME in /etc/sysconfig/network.In my case it was set as Sendmail_BLR.utiisl.co.in

manicks         manicks@Sendmail_BLR.utiisl.co.in
bspandit        bspandit@Sendmail_BLR.utiisl.co.in

manicks         manicks@gsd.utiisl.co.in
      bspandit        bspandit@gsd.utiisl.co.in

 

postman@islbom2.utiisl.co.in
      postman@islbom2.utiisl.co.in
      password_of_postman_user_on_islbom2_created_using_saslpassword
   
 
islbom2.utiisl.co.in  # Name of realm
This file should have the permission 700 only and should not be world-readable.

            hosts                files
   
               aliases             files

 In sendmail.cf comment out the line : 
            #O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA 

            and also comment the line : 
            #R$* $: $>MasqEnv $1 do masquerading

            For Ruleset 94 put:
            SMasqEnv=94
            R$+ $@ $>EnvelopeRewrite $1

Here is a small script which may be used to create a user on the SMART Host mail server. 

 


INSTALLATION OF SENDMAIL + CYRUS-SASL ON MAIL RELAY SERVER

Download cyrys-sasl from here . I have downloaded the version 1.5.28.  Then login as root on the Relay Server
tar -xvf cyrus-sasl-1.5.28.tar

# cd cyrus-sasl-1.5.28

 

# ./configure --enable-login

# make

# make install

# cd /usr/local/

# cd lib

# cd sasl

 in the file  saslpassword.conf and Sendmail.conf in /usr/local/lib/sasl put the line : 
       pwcheck_method: sasldb

#cp -rf /usr/local/lib/sasl /usr/lib

# cp /usr/local/lib/libsasl* /usr/lib

# cd /usr/lib

# ls -al libsasl*

# rm -i libsasl.so libsasl.so.7

# ln -s libsasl.so.7.1.11 libsasl.so

# ln -s libsasl.so.7.1.11 libsasl.so.7

# chmod -R 500 /usr/local/lib/sasl /usr/local/lib/libsasl* /usr/lib/sasl /usr/lib/libsasl*

# cd /etc

In the file  ld.so.conf   put the line 
    /usr/lib/sasl 
at the end.

# ldconfig

Now we have to Build Sendmail from the sourcefile. Copy the sendmail.tar.gz file to /root and run the followign commands:

# cd /root
# gunzip sendmail-8.12.3.tar.gz
# tar -xvf sendmail-8.12.3.tar

cd sendmail-8.12.3/devtools/Site

vi site.config.m4 
and add the following lines:
APPENDDEF(`confENVDEF', `-DSASL')
APPENDDEF(`conf_sendmail_LIBS', `-lsasl')
APPENDDEF(`confLIBDIRS', `-L/usr/lib/sasl')
APPENDDEF(`confINCDIRS', `-I/usr/include')

chown -R root:root sendmail-8.12.3/

cd sendmail-8.12.3/

cd cf

cd cf

l

vi generic-linux.mc

Create a sendmail.mc in the cf/cf directory. A sample copy is available here

From the root directory of sendmail run  
# sh ./Build

Check the following after completion 
#/usr/sbin/sendmail -d0.1 -bv root |grep SASL. This should show 
            NETINET NETUNIX NEWDB PIPELINING SASL SCANF USERDB XDEBUG

Start sendmail using :
# /etc/rc.d/init.d/sendmail start

telnet localhost 25. If this connects then you are through.

Create a SASL-user using which the remote mailserver would connect. This password should be put in the authinfo.txt file in /etc/mail directory of the remote mail server.

./saslpasswd postman

./sasldblistusers.