| ||||
随着互联网的发展,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但这个仅仅表示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来查看是不是已经更改了.
[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的监听端口现在是eth0的ip地址:192.168.100.134了.
# Check the /usr/share/doc/SendMail-8.11.2/README.cf file for a description # of the format of this file. (search for access_db in that file) # The /usr/share/doc/SendMail-8.11.2/README.cf is part of the SendMail-doc # package. # # by default we allow relaying from localhost... localhost.localdomain RELAY localhost RELAY 127.0.0.1 RELAY blank.com RELAY 然后运行: [root@testmail mail]# make access.db [root@testmail mail]#这个make access.db命令把你的新的设定添加到SendMail的hash数据库里.SendMail用它来判断允许那些主机通过你的e-mail服务器来传递邮件.而且这样还可以通过设定子网(例如:192.168)来限制该域.但你要注意,这样设定就对外开放了,可能会有人发大量的垃圾信件来攻击你的系统.
[root@testmail mail]# mount /dev/cdrom /mnt/cdrom mount: block device /dev/cdrom is write-protected, mounting read-only (Successful Mount of Read-Only Media)mount上光盘后运行这个命令来安装这个包:rpm -Uvh /mnt/cdrom/RedHat/RPMS/imap-2000-9.i386.rpm.
[root@testmail mail]# rpm -Uvh /mnt/cdrom/RedHat/RPMS/imap-2000-9.i386.rpm Preparing... ########################################### [100%] 1:imap ########################################### [100%] 再运行一次 rpm -aq | grep -i imap IMAP 包就罗列出来了。 [root@testmail mail]# rpm -aq | grep -i imap imap-2000-9 [root@testmail mail]#当正确的包被安装后你要打开POP3的连接端口,这需要修改/etc/xinetd.d/下面的ipop3文件,把disable的值改成no。这个文件大致是这样的:
# default: off
# description: The POP3 service allows remote users to access their mail
# using an POP3 client such as Netscape Communicator, mutt,
# or fetchmail.
service pop3
{
socket_type = stream
wait = no
user = root
server = /usr/sbin/ipop3d
log_on_success += USERID
log_on_failure += USERID
disable = no
}
接下去重新启动xinetd来是它生效:
[root@testmail xinetd.d]# /etc/init.d/xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@testmail xinetd.d]#
现在就可以发送一封测试邮件到你的e-mail服务器,并且用你熟悉的收信工具来收取这封信。应该是没有问题的。# timeouts (many of these) #O Timeout.ident=5s change to O Timeout.ident=1s现在你的e-mail服务器可以给你的用户提供服务了。当然还有更多的配置可以用来提高服务器性能,在这篇文章中就不多提了。Linux将会为你的e -mail服务提供一个稳定的,高效的平台。如果想了解更多的关于SendMail的知识,请访问www.SendMail.org.
电子商务辩论台: |
|
载入中…
|