linux sendmal 安装[一]

Share

      公司换了服务器,需要重新配置一个mail服务器,所以顺便写下了这个手札。
      准备工作下载:ftp://ftp.sendmail.org/pub/sendmail/sendmail.8.13.8.tar.gz
                              ftp://ftp.feep.net/pub/software/nph/nph-1.2.3.tar.gz

      安装:
      [lee@icnote src ]#tar zvxf nph-1.2.3.tar.gz
      [lee@icnote src ]#./configure
      [lee@icnote src ]#make
      [lee@icnote src ]#make install
      [lee@icnote src ]#cd /usr/local/src
      [lee@icnote src ]#tar zxvf sendmail.8.13.8.tar.gz
      [lee@icnote src ]#cd sendmail-8.13.8

      [lee@icnote src ]#vi devtools/Site/site.config.m4
添加:
APPENDDEF(`confENVDEF',`-DSASL=2')
APPENDDEF(`conf_sendmail_LIBS',`-lsasl2')
APPENDDEF(`confMAPDEF', `-DPH_MAP')dnl
APPENDDEF(`confINCDIRS', `-I/path/to/phclient/hdrs')dnl
APPENDDEF(`confLIBDIRS', `-L/path/to/phclient/libs')dnl
APPENDDEF(`confLIBS', `-lphclient')dnl

Replace /path/to/phclient/hdrs with the include path which contains the phclient.h file (e.g., /usr/local/include). Also replace /path/to/phclient/libs with the path which contains the libphclient.a library (e.g., /usr/local/lib).

      [lee@icnote src ]#sh Build
      [lee@icnote src ]#mkdir -pv /usr/man/man1
      [lee@icnote src ]#sh Build install

      [lee@icnote src ]#mkdir -pv /usr/share/sendmail
      [lee@icnote src ]#cp -a cf /usr/share/sendmail
      [lee@icnote src ]#mkdir /var/spool/mqueue

      [lee@icnote src ]#cd cf/cf
      [lee@icnote src ]#cp generic-linux.mc sendmail.mc
      [lee@icnote src ]#make install-cf
      [lee@icnote src ]#cp sendmail.mc /etc/mail

      [lee@icnote src ]#cd /etc/mail
      [lee@icnote src ]#touch aliases access
      [lee@icnote src ]#echo “icnote.com”>local-host-names
      [lee@icnote src ]#echo “mail.icnote.com”>>local-host-names
      [lee@icnote src ]#echo “localhost  RELAY” >> access
      [lee@icnote src ]#echo “127.0.0.1  RELAY” >> access
      [lee@icnote src ]#makemap hash access.db       [lee@icnote src ]#sendmail -bd -q30m

注:Sendmail的命令参数的含义如下:

   -b:指定Sendmail在后台运行,并且监听端口25的请求。
   -d:指定Sendmail以Daemon方式运行(守护进程)。
   -q:当Sendmail无法将邮件成功地发送到目的地时,它会将邮件保存在队列里。该参数指定邮件在队列里保存的时间。例子里的30m表示保留30分钟。

3.测试发信

#netstat -tnlp |grep :25
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      4636/

      [lee@icnote src ]#useradd test    (添加一个测试用户)
      [lee@icnote src ]#passwd test

      [lee@icnote src ]#echo “root:test” >> /etc/mail/aliases
      [lee@icnote src ]#newaliases

开始连接服务器并测试发信
      [lee@icnote src ]#telnet localhost 25
mail from:root@mydomain.org
rcpt to:test@mydomain.org
data
THis is a test!!
.
quit

通过发信日志查看邮件发送状态
      [lee@icnote src ]#tail -20 /var/log/maillog

也可以通过outlook来测试发信。