·建站首页 ·钻石 ·繁體
您的位置: 中国建站之家 -> 服务器应用 -> 邮件服务器 -> 配置你的第一台e-mail服务器(上)

配置你的第一台e-mail服务器(上)

作者:未知  来源:转载  发布时间:2005-7-20 8:19:05  发布人:acx

  随着互联网的发展,e-mail迅速成长成为主要的网络信息传递工具。面对大量要求能够快速,廉价,和高可信赖的e-mail需求,很多公司和个人都把linux提供的服务作为满足这些需求的解决方案。

  SendMail最初是1979年由Eric Allman编写而成。它起先运行在BSD 4.0平台上。但这个程序不够灵活,每次编译的时候都需要重新配置。随着TCP协议和其他方面的发展,它本身的不灵活性已经明显不能满足日益增长的需求。Eric Allman决定重新编写SendMail,从而诞生了现在的MTA标准。这是对SendMail的简短介绍.我们这篇文章主要是示范如何在一台新装的redhat 7.1上用配置SendMail8.11.2 服务,构架你的e-mail服务器.
redhat7.1默认安装的时间已经安装了SendMail 8.11服务.因为redhat安装使用都非常的简单,我们这里就忽略安装过程,相关资料请查阅redhat CD里的文档.要使你的新e-mail服务器正常工作,必须先解决DNS问题.把你的e-mail服务器的主机名和ip地址加入到DNS中,并用nslookup来确认:

  [root@testmail /root]# nslookup -sil testmail.blank.com
  Server: 192.168.100.1
  Address: 192.168.100.1#53

  Name: testmail.blank.com
  Address: 192.168.100.134

  同样你也要试一下反向域名解析,这个对防止邮件延迟有很重要的作用.现在大部分的邮件服务器都是把反向域名解析作为邮件传送时认证的一部分.所以用的你ip地址来试一下反向域名解析是否正确.

  [root@testmail /root]# nslookup -sil 192.168.100.134
  Server: 192.168.100.1
  Address: 192.168.100.1#53

  134.100.168.192.in-addr.arpa name = TESTMAIL.blank.com.

  正如你所看到的,DNS服务工作正常,接下去就让我们动手来配置SendMail服务.redhat 7.1 默认安装已经可以使SMTP服务在本机运行.

  你用netstat -nl可以看到所有后台程序监听的端口,注意这一行:127.0.0.1:25,这个表示SendMail服务已经在监听本机的25(SMTP)端口了:

  [root@testmail /root]# netstat -nl
  Active Internet connections (only servers)
  Proto Recv-Q Send-Q Local Address Foreign Address State
  tcp 0 0 0.0.0.0:32768 0.0.0.0:* LISTEN
  tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
  tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
  tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
  udp 0 0 0.0.0.0:32768 0.0.0.0:*
  udp 0 0 0.0.0.0:667 0.0.0.0:*
  udp 0 0 0.0.0.0:111 0.0.0.0:*
  Active UNIX domain sockets (only servers)
  Proto RefCnt Flags Type State I-Node Path
  unix 2 [ ACC ] STREAM LISTENING 1119 /dev/gpmctl
  unix 2 [ ACC ] STREAM LISTENING 1172 /tmp/.font-unix/fs7100 [page]

  但这个仅仅表示e-mail服务器只接收你本机的邮件.为了解决这个问题,你必须修改配置,告诉SendMail去监听你对外的网卡地址.假设你的服务器上只安装了一块网卡(eth0),并用ifconfig配置好你的ip地址.这个地址可以和DNS解析的地址不一样,但你要保证DNS可以正确地解析邮件服务器的地址.这里我们使用的地址是一样的(推荐):

  [root@testmail /root]# ifconfig
  eth0 Link encap:Ethernet HWaddr 00:60:97:DE:E9:99
  inet addr:192.168.100.134 Bcast:192.168.100.255 Mask:255.255.255.0
  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  RX packets:12421 errors:0 dropped:0 overruns:0 frame:0
  TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:100
  Interrupt:10 Base address:0xe000

  lo Link encap:Local Loopback
  inet addr:127.0.0.1 Mask:255.0.0.0
  UP LOOPBACK RUNNING MTU:16436 Metric:1
  RX packets:6 errors:0 dropped:0 overruns:0 frame:0
  TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:0

  可以看到这台主机的eth0的ip地址是192.168.100.134.现在修改/etc/SendMail.cf文件来配置SendMail的监听端口:

  # SMTP daemon options
  O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA

  更改为

  O DaemonPortOptions=Port=smtp,Addr=192.168.100.134, Name=MTA

  改完后保存退出,并且重新启动SendMail服务:

  [root@testmail /root]# /etc/init.d/SendMail restart
  Shutting down SendMail: [ OK ]
  Starting SendMail: [ OK ]
  [root@testmail /root]#

  现在可以用netstat -nl来查看是不是已经更改了.如你所看到的,SendMail的监听端口现在是eth0的ip地址:192.168.100.134了.
  [root@testmail /root]# netstat -nl
  Active Internet connections (only servers)
  Proto Recv-Q send-Q Local Address Foreign Address State
  tcp 0 0 0.0.0.0:32768 0.0.0.0:* LISTEN
  tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
  tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
  tcp 0 0 192.168.100.134:25 0.0.0.0:* LISTEN
  udp 0 0 0.0.0.0:32768 0.0.0.0:*
  udp 0 0 0.0.0.0:667 0.0.0.0:*
  udp 0 0 0.0.0.0:111 0.0.0.0:*
  Active UNIX domain sockets (only servers)
  Proto RefCnt Flags Type State I-Node Path
  unix 2 [ ACC ] STREAM LISTENING 1119 /dev/gpmctl
  unix 2 [ ACC ] STREAM LISTENING 1172 /tmp/.font-unix/fs7100
  [root@testmail /root]#

  ///////////////////////////////////////////////////////////////

  现在SendMail已经可以接收来自外部的连接了.我们还需要设定SendMail允许接收的域名.这个可以在/etc/mail/local-host-names文件中设定.就把域名输入进去就可以了:

  # local-host-names - include all aliases for your machine here.
  blank.com

  保存退出后重新启动SendMail服务:/etc/init.d/SendMail restart .这样SendMail就可以接收来自多个域的信件了.

  如果你需要再增加新的域,只有修改这个文件就可以了.

将本文收藏到QQ书签与更多好友分享

上一篇:Sendmail 554 错误的解决

下一篇:配置你的第一台e-mail服务器(下)