原代码安装配置sendmail
*******************************************
先确认网络环境:
ifconfig eth0
./host -t MX mihost.kmip.net
mihost.kmip.net mail is handled by 0 mail.mihost.kmip.net.
./host -t MX benet.com
编译安装过程
解压缩原代码
tar zxvf sendmail.8.13.8.tar.gz
手动生成m4文件,内容如下:
cd sendmail-8.13.8/
vi devtools/Site/site.config.m4
APPENDDEF(`confENVDEF',`-DSASL=2')
APPENDDEF(`conf_sendmail_LIBS',`-lsasl2')
编译
sh Build –c #可能编译时会出错!!
sh Build install
确保m4安装了
rpm -q m4
m4-1.4.1-13
建立sendmail目录
mkdir /usr/share/sendmail
cp -a cf /usr/share/sendmail
生成sendmail.mc文件
cd cf/cf
cp generic-linux.mc sendmail.mc
more sendmail.mc
建立sendmail工作目录
mkdir /etc/mail
安装
make install-cf
cp sendmail.mc /etc/mail/
生成配置文件
cd /etc/mail
touch aliases access
echo "mihost.kmip.net" >local-host-names
echo "mail.mihost.kmip.net">>local-host-names
cat local-host-names
生成access.db、aliases.db
makemap hash access < access
makemap hash aliases < aliases
启动sendmail
mkdir /var/spool/mqueue
/usr/sbin/sendmail -bd -q1h #后台执行,且每小时处理一次邮件队列
ps -aux | grep sendmail
测试发信
确认25端口开启了
netstat -tnl | grep :25
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
增加帐号redhat作为root的别名
useradd redhat
passwd redhat
echo "root:redhat" >>/etc/mail/aliases
newaliases #让aliases生效
连接服务器测试发信
[root@RHL9 root]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 localhost.localdomain ESMTP Sendmail 8.13.8/8.13.8; Thu, 8 Mar 2007 02:35:46 +0800
mail from: root@mihost.kmip.net
250 2.1.0 root@mihost.kmip.net... Sender ok
rcpt to: redhat@mihost.kmip.net
250 2.1.5 redhat@mihost.kmip.net... Recipient ok
data
354 Enter mail, end with "." on a line by itself
hello,mail from smtp command.
.
250 2.0.0 l27IZkc9006279 Message accepted for delivery
quit
221 2.0.0 localhost.localdomain closing connection
Connection closed by foreign host.
[root@RHL9 root]# tail /var/log/maillog
Mar 8 02:37:57 RHL9 sendmail[6279]: l27IZkc9006279: from=root@mihost.kmip.net, size=30, class=0, nrcpts=1, msgid=<200703071836.l27IZkc9006279@localhost.localdomain>, proto=SMTP, daemon=MTA, relay=RHL9 [127.0.0.1]
Mar 8 02:37:57 RHL9 sendmail[6660]: l27IZkc9006279: to=redhat@mihost.kmip.net, ctladdr=root@mihost.kmip.net (0/0), delay=00:00:58, xdelay=00:00:00, mailer=local, pri=30443, dsn=2.0.0, stat=Sent
[root@RHL9 root]# cat /var/mail/redhat
From root@mihost.kmip.net Thu Mar 8 02:37:57 2007
Return-Path: <root@mihost.kmip.net>
Received: from RHL9 (RHL9 [127.0.0.1])
by localhost.localdomain (8.13.8/8.13. with SMTP id l27IZkc9006279
for redhat@mihost.kmip.net; Thu, 8 Mar 2007 02:36:59 +0800
Date: Thu, 8 Mar 2007 02:35:46 +0800
From: root <root@mihost.kmip.net>
Message-Id: <200703071836.l27IZkc9006279@localhost.localdomain>
X-Authentication-Warning: localhost.localdomain: RHL9 [127.0.0.1] didn't use HELO protocol
hello,mail from smtp command.
用outlook测试发信
然后切换到redhat用mail来收信
[root@RHL9 root]# su - redhat
[redhat@RHL9 redhat]$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/redhat": 2 messages 2 new
>N 1 root@mihost.kmip.net Thu Mar 8 02:37 12/487
N 2 redhat@mihost.kmip.net Thu Mar 8 02:54 42/1545 "Hello,Test from outlo"
& 2