分类: LINUX
2009-06-26 22:47:15
[root@srv-34 /root]# rpm -qa | grep sendmail sendmail-8.11.2-14 sendmail-cf-8.11.2-14 [root@srv-34 /root]# rpm -e sendmail-cf-8.11.2-14 [root@srv-34 /root]# rpm -e sendmail-8.11.2-14 error: removing these packages would break dependencies: smtpdaemon is needed by fetchmail-5.7.4-4 smtpdaemon is needed by mutt-1.2.5i-9 [root@srv-34 /root]# rpm -e fetchmail-5.7.4-4 [root@srv-34 /root]# rpm -e mutt-1.2.5i-9 [root@srv-34 /root]# rpm -e sendmail-8.11.2-14 [root@srv-34 /root]#All gone. Now let's extract the latest sendmail from :
[root@srv-34 /root]# cd /usr/local/src [root@srv-34 src]# ls sendmail.8.11.4.tar.gz [root@srv-34 src]# [root@srv-34 src]# tar -xzf *.gz [root@srv-34 src]# ls sendmail-8.11.4 sendmail.8.11.4.tar.gz [root@srv-34 src]# cd send* [root@srv-34 sendmail-8.11.4]#
Now let's build sendmail:
[root@srv-34 sendmail-8.11.4]# sh Build Making all in: /usr/local/src/sendmail-8.11.4/libsmutil . . . cc -O -I. -I../../sendmail -I../../include -DNEWDB -DNOT_SENDMAIL -c -o vacation.o vacation.c cc -o vacation vacation.o ../libsmdb/libsmdb.a ../libsmutil/libsmutil.a -ldb -lresolv -lcrypt -lnsl -ldl groff -Tascii -man vacation.1 > vacation.0 || cp vacation.0.dist vacation.0 make[1]: Leaving directory `/usr/local/src/sendmail-8.11.4/obj.Linux.2.4.2-2.i586/vacation' [root@srv-34 sendmail-8.11.4]#
All good. Now what we want to do is build a config.cf file and copy it to /etc/mail.
[root@srv-34 sendmail-8.11.4]# cd cf/cf [root@srv-34 cf]# [root@srv-34 cf]# ls Build generic-bsd4.4.mc generic-solaris2.cf Makefile chez.cs.mc generic-hpux10.cf generic-solaris2.mc python.cs.mc clientproto.mc generic-hpux10.mc generic-sunos4.1.cf s2k-osf1.mc cs-hpux10.mc generic-hpux9.cf generic-sunos4.1.mc s2k-ultrix4.mc cs-hpux9.mc generic-hpux9.mc generic-ultrix4.cf tcpproto.mc cs-osf1.mc generic-linux.cf generic-ultrix4.mc ucbarpa.mc cs-solaris2.mc generic-linux.mc huginn.cs.mc ucbvax.mc cs-sunos4.1.mc generic-nextstep3.3.cf knecht.mc uucpproto.mc cs-ultrix4.mc generic-nextstep3.3.mc mail.cs.mc vangogh.cs.mc cyrusproto.mc generic-osf1.cf mail.eecs.mc generic-bsd4.4.cf generic-osf1.mc mailspool.cs.mc [root@srv-34 cf]# [root@srv-34 cf]# cat generic-linux.mc divert(-1) # # Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers. # All rights reserved. # Copyright (c) 1983 Eric P. Allman. All rights reserved. # Copyright (c) 1988, 1993 # The Regents of the University of California. All rights reserved. # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of # the sendmail distribution. # # # # This is a generic configuration file for Linux. # It has support for local and SMTP mail only. If you want to # customize it, copy it to a name appropriate for your environment # and do the modifications there. # divert(0)dnl VERSIONID(`$Id: generic-linux.mc,v 8.1 1999/09/24 22:48:05 gshapiro Exp $') OSTYPE(linux)dnl DOMAIN(generic)dnl MAILER(local)dnl MAILER(smtp)dnl [root@srv-34 cf]# [root@srv-34 cf]# mkdir /etc/mail [root@srv-34 cf]# [root@srv-34 cf]# mkdir /var/spool/mqueue [root@srv-34 cf]# [root@srv-34 cf]# cp generic-linux.mc config.mc [root@srv-34 cf]# sh Build config.cf Using M4=/usr/bin/m4 rm -f config.cf /usr/bin/m4 ../m4/cf.m4 config.mc > config.cf || ( rm -f config.cf && exit 1 ) chmod 444 config.cf [root@srv-34 cf]# [root@srv-34 cf]# cp config.cf /etc/mail/sendmail.cf [root@srv-34 cf]#We need to go back a couple of directories to the root of the sendmail source tree and install sendmail:
[root@srv-34 cf]# cd .. [root@srv-34 cf]# cd .. [root@srv-34 sendmail-8.11.4]# sh Build install Making all in: /usr/local/src/sendmail-8.11.4/libsmutil . . . install -c -o bin -g bin -m 444 vacation.0 /usr/man/man1/vacation.1 install: cannot create regular file `/usr/man/man1/vacation.1': No such file or directory make[1]: *** [install-docs] Error 1 make[1]: Leaving directory `/usr/local/src/sendmail-8.11.4/obj.Linux.2.4.2-2.i586/vacation' make: *** [all] Error 2 [root@srv-34 sendmail-8.11.4]#Hmmmm... Notice how the path for the man pages is wrong? They should be in /usr/share/man. What we can do to solve this is to copy /usr/local/src/sendmail-8.11.4/devtools/OS/Linux to /usr/local/src/sendmail-8.11.4/devtools/Site/site.config.m4, and edit it so that we have:
[root@srv-34 Site]# pwd /usr/local/src/sendmail-8.11.4/devtools/Site [root@srv-34 Site]# ls Linux README site.config.m4 [root@srv-34 Site]# cat site.config.m4 # $Id: Linux,v 8.18.4.3 2000/12/14 01:04:46 rand Exp $ define(`confDEPEND_TYPE', `CC-M') define(`confMANROOT', `/usr/share/man/man') define(`confLIBS', `-ldl') define(`confEBINDIR', `/usr/sbin') APPENDDEF(`confLIBSEARCH', `crypt nsl') define(`confLD', `ld') define(`confMTLDOPTS', `-lpthread') define(`confLDOPTS_SO', `-shared') define(`confSONAME',`-soname') ifelse(confBLDVARIANT, `DEBUG', dnl Debug build ` define(`confOPTIMIZE',`-g -Wall') ', dnl Optimized build confBLDVARIANT, `OPTIMIZED', ` define(`confOPTIMIZE',`-O') ', dnl Purify build confBLDVARIANT, `PURIFY', ` define(`confOPTIMIZE',`-g -Wall') ', dnl default ` define(`confOPTIMIZE',`-O') ') [root@srv-34 Site]#Now, we can try again. We need to use the -c option because we changed the configuration:
[root@srv-34 sendmail-8.11.4]# sh Build -c -f /usr/local/src/sendmail-8.11.4/devtools/Site/site.config.m4 install Making all in: /usr/local/src/sendmail-8.11.4/libsmutil Configuration: pfx=, os=Linux, rel=2.4.2-2, rbase=2, rroot=2.4, arch=i586, sfx=, variant=optimized . . . -ldb -lresolv -lcrypt -lnsl -lcrypt -lnsl -ldl install -c -o bin -g bin -m 555 vacation /usr/bin groff -Tascii -man vacation.1 > vacation.0 || cp vacation.0.dist vacation.0 install -c -o bin -g bin -m 444 vacation.0 /usr/share/man/man1/vacation.1 make[1]: Leaving directory `/usr/local/src/sendmail-8.11.4/obj.Linux.2.4.2-2.i586/vacation' [root@srv-34 sendmail-8.11.4]#OK. That worked. We need to create an empty (for now) local-host-names file:
[root@srv-34 mail]# cat /dev/null > local-host-namesLet's go over to srv-33 and do the same thing, but this time we will run a mail daemon. We need to create a /etc/aliases.db file. For now, we will just create an empty /etc/aliases and run newaliases:
[root@srv-33 /root]# cat /dev/null > /etc/aliases [root@srv-33 /root]# newaliases /etc/mail/aliases: 0 aliases, longest 0 bytes, 0 bytes total [root@srv-33 /root]#Let's start the daemon manually:
[root@srv-33 sendmail-8.11.4]# sendmail -bd -q30mNow, on srv-34... First, let's send mail:
[root@srv-34 log]# sendmail u-1@srv-33 test from srv-34 .Now, let's check the logs on srv-34:
[root@srv-34 log]# [root@srv-34 log]# cat /var/log/maillog . . . Jun 11 13:49:15 srv-34 sendmail[10794]: f5BKmwd10794: from=root, size=19, class=0, nrcpts=1, msgid=<200106112048.f5BKmwd10794@srv-34.signalq.com>, relay=root@localhost Jun 11 13:49:15 srv-34 sendmail[10796]: f5BKmwd10794: to=u-1@srv-33, ctladdr=root (0/0), delay=00:00:17, xdelay=00:00:00, mailer=esmtp, pri=30019, relay=srv-33.signalq.com. [10.50.100.51], dsn=2.0.0, stat=Sent (f5BKlg906302i Message accepted for delivery) [root@srv-34 log]#OK. Let's get our mail via pine on srv-34, logging on to the u-1 account on srv-33 via IMAP:
[root@srv-34 sendmail-8.11.4]# pine PINE 4.33 MESSAGE TEXT Folder: INBOX Message 3 of 3 ALL Return-Path:We can see this stuff on srv-33's logs:Received: from srv-34.signalq.com (srv-34.signalq.com [10.50.100.53]) by srv-33.signalq.com (8.11.4/8.11.4) with ESMTP id f5BKlg906302 for ; Mon, 11 Jun 2001 13:47:42 -0700 Received: (from root@localhost) by srv-34.signalq.com (8.11.4/8.11.4) id f5BKmwd10794 for u-1@srv-33; Mon, 11 Jun 2001 13:48:58 -0700 Date: Mon, 11 Jun 2001 13:48:58 -0700 From: root Message-Id: <200106112048.f5BKmwd10794@srv-34.signalq.com> test from srv-34 [Already at end of message] ? Help J Jump H HdrMode * Flag O OTHER CMDS : SelectCur Tab NextNew B Bounce | Pipe
[root@srv-33 mail]# cat /var/log/maillog
Jun 11 13:47:42 srv-33 sendmail[6302]: f5BKlg906302: from=Let's start sendmail automatically by adding: /usr/sbin/sendmail -bd -q30m to the bottom of /etc/rc.d/rc.local., size=302, class=0, nrcpts=1, msgid=<200106112048.f5BKmwd10794@c allisto .signalq.com>, proto=ESMTP, daemon=MTA, relay=srv-34.signalq.com [10.5 0.100.53] Jun 11 13:47:42 srv-33 sendmail[6303]: f5BKlg906302: to= , delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30026, dsn=2.0. 0, stat=Sent Jun 11 13:48:26 srv-33 imapd[6305]: imap service init from 10.50.100.53 Jun 11 13:48:32 srv-33 imapd[6305]: Authenticated user=u-1 host=srv-34.s ignalq.com [10.50.100.53]
Do note that we have configured very little here, and we have not addressed security issues. We will cover this in other articles.