!!! Do you know that Sun decided to defer Solaris on Intel ? For more information : go Save Solaris x86

"Instant noodle" or step-by-step installation of sendmail 8.10.x or above with pop-before-smtp support

For details of sendmail , please have a look at www.sendmail.org/~ca, or participate to the sendmail newsgroup.
This note is only step-by-step for installing sendmail, without going thru all the README files in the sendmail package. This work was done on a Solaris for Intel. Similar steps was also done on a Linux box but with previous packages of Berkeyley DB, and sendmail.

Packages such as gcc, make, binutils ... are assumed already installed.

If you are using 8.11.x or lower, skip step 1

1. Create smmsp user and group ( 8.12.x only )

$ groupadd smmsp
$ useradd -g smmsp smmsp
Be careful, group smmsp must be the primary group of user smmsp.
Also check the following permissions after installing sendmail. ( For more information, see sendmail/SECURITY )
-r-xr-sr-x      root   smmsp    ... /PATTH/TO/sendmail
drwxrwx---      smmsp  smmsp    ... /var/spool/clientmqueue
drwx------      root   dt164    ... /var/spool/mqueue
-r--r--r--      root   dt164    ... /etcc/mail/sendmail.cf
-r--r--r--      root   dt164    ... /etcc/mail/submit.cf

2. Install the Berley DB

Download this libray from http://www.sleepycat.com/
$ tar xzf db-4.0.14.tar.gz
$ cd db-4.0.14
$ cd build_unix
$ ../dist/configure
$ make
( must be root to do make install )
$ make install

3. Build sendmail

Download sendmail from www.sendmail.org
$ tar xzf  sendmail.8.11.6.tar.gz
$ cd sendmail.8.11.6/devtools/Site
Create a file called site.config.m4 in devtools/Site with the following content:
define(`confMAPDEF', `-DNEWDB')dnl
define(`confINCDIRS',`-I/usr/local/BerkeleyDB.4.0/include')dnl
define(`confLIBDIRS',`-L/usr/local/BerkeleyDB.4.0/lib')dnl

$ cd ../..
$ LD_LIBRARY_PATH=/usr/local/lib:/usr/local/BerkeleyDB4.0/lib
$ export LD_LIBRARY_PATH
$ sh Build 
$ sh Build install
On Solaris 8, the last step will not copy mail.local to /usr/lib. I did it manually. See mail.local/README for more details.

4. Build sendmail.cf .

Copy the the popauth.m4 into cf/hack.
Create the file myconfig.mc in cf/cf with the followings:
include(`../m4/cf.m4')dnl
OSTYPE(`solaris8')dnl       <--( change this to your OS )
FEATURE( `access_db')dnl
FEATURE( `use_cw_file')dnl
HACK(`popauth')dnl
MAILER( `smtp')dnl

$ m4 myconfig.mc > sendmail.cf
$ cp sendmail.cf /etc/mail
Edit /etc/mail/local-host-names that contains the domains that this sendmail server manages, each domain per lines. Of course, you must have MX records declared on DNS server.

5. Build your aliases.db and access.db

Create your /etc/mail/aliases and /etc/mail/access. These files may be empty files if you don't care about aliases and access.
$ cd /etc/mail
$ touch aliases
$ touch access
( edit these files according to your need. See cf/README )
$ newaliases
$ makemap hash access < access
You may need to create directory /var/spool/mqueue if it does not exists.

6 Start sendmail

For sendmail below 8.12
/usr/lib/sendmail -bd -q1h

For sendmail 8.12
/usr/lib/sendmail -L sm-mta -bd -q1h
/usr/lib/sendmail -L sm-msp-queue -Ac -q30m

If you see some permission errors here, be sure that there is no write permission for group/other on /etc/mail.

To know if your sendmail works, try this.

7. Installtion qpopper

Download qpopper from http://www.qpopper.com/qpopper/
$ tar xzf  qpopper4.0.3.tar.gz
$ cd qpopper4.0.3
$ ./configure --enable-specialauth --enable-log-login
$ make
$ cp popper/popper /usr/local/bin
Prepare the inetd.conf
Edit the /etc/inetd.conf to have the following line:
pop3    stream  tcp     nowait  root    /usr/local/sbin/popper  qpopper -s
then restart inetd daemon by sending it a -HUP signal.

Note for Redhat 7 or later: RH7 uses xinetd instead of inetd. You need to create a xinetd control file for qpopper in /etc/xinetd.d as

service pop3                                                                    
{                                                                               
        disable = no                                                            
        flags           = REUSE                                                 
        socket_type     = stream                                                
        wait            = no                                                    
        user            = root                                                  
        server          = /usr/local/sbin/popper                                
        server_args     = qpopper -s                                            
        log_on_failure  += USERID                                               
}    

8. syslog and pop-before-smtp program

Qpopper logs its info into local0.info or mail.info. Therefore be sure to have this line in /etc/syslog.conf
local0.info            /var/log/mail
or
mail.info            /var/log/mail

If you use imap4, then it will be mail.info.
mail.info            /var/log/mail

create an empty /var/log/mail ( by using touch /var/log/mai; ) and then restart syslog.

Check if your pop3 server works.
Check if your imap4 server works.

Now grab this mailwatch source and compile it ( gcc -o mailwatch mailwatch.c ). Copy the binary mailwatch into /usr/local/bin, create directory /etc/mail/popipspool, then create the initscript mailwatch for loading mailwatch at startup:

case "$1" in
        start)
                # first parm: log file
                # 2nd parm : ip spool directory
                # 3rd parm : timeout of ip addresses
                /usr/local/bin/mailwatch /var/log/mail /etc/mail/popipspool 900
                ;;
        stop)
                kill -9 `cat /etc/mailwatch.pid`
                ;;
        *)
                echo "popwatch start | stop"
                ;;
esac
exit 0
Copy this script file mailwatch into /etc/init.d ( for Solaris ) or /etc/rc.d/init.d ( for Linux ), change its permission to executable then create the corresponding symlink depending on init-level that your server starts.For example
# cd /etc/rc3.d        ( or cd /etc/rc.d/rc3.d - if Linux )
# ln -s ../init.d/mailwatch S99mailwatch

Run this script

Check if pop3/imapd logs to syslog by loggin in to pop3 or imapd server to see if /var/log/mail consists of the logs like:

Dec 30 14:47:50 sun1 qpopper[6760]: (v4.0.3) POP login by user "dt164" at (ppp07-294.algx-houston.pdq.net) 209.196.109.40
Dec 30 14:47:50 sun1 qpopper[6760]: Stats: dt164 0 0 0 0 ppp07-294.algx-houston.pdq.net 209.196.109.40
Check if mailwatch works by logging in pop3/imapd server and see if /etc/mail/pophash.tmp contains lines like
68.215.181.130 OK
209.196.109.40 OK