lenson 发表于 2007-10-24 14:48:00

架设sendmail服务器

前提:首先我们 把DNS服务器安装OK 能够解析.(或者在hosts文件中添加域名和IP的对应。)
1,首先安装Sendmail所需软件
# rpm -q sendmail m4
sendmail-8.13.1-2
默认是安装了的,若没有还需挂载第4张光盘,安装与sendmail相关的软件
# rpm -ivh sendmail-*
warning: sendmail-cf-8.13.1-2.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ###########################################
(1):sendmail-doc ########################################### [ 33%]
(2):sendmail-cf ########################################### [ 67%]
(3):sendmail-devel ###########################################
2.修改/etc/mail/local-hosts-name文件。
增加本地域和主机的FQDN,记住只是本地主机的FQDN和域名FQDN,不要添加其他域的,否则向外域发送邮件的时候会出现user unknown的错误:
# cat /etc/mail/local-host-names
# local-host-names - include all aliases for your machine here.
boway.edu
3, 更改/etc/mail/sendmail.mc文件,修改下列地方:
DaemonPortsOptions=Port=smtp,Addr=127.0.0.1, Name=MTA 更改为:
DaemonPortsOptions=Port=smtp,Addr=你本机ip, Name=MTA
然后m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
4, 用户管理
认证的配置:修改/etc/mail/sendmail.mc中的字段,取消“TRUST_AUTH_MECH”一行和下一行“define”处的注释。(于sendmail.mc文件的第48、49)然后m4 /etc/ mail/sendmail.mc>/etc/mail/sendmail.cf。
# chkconfig --list saslauthd 开启认证
saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
# chkconfig --level 35 saslauthd on
建立用户帐号
# adduser lenson
# adduser user1
# passwdlenson
# passwduser1 密码都是123
设置邮件别名和邮件群发
修改/etc/aliases文件实现邮件转发和邮件列表:
admin: lenson 为邮件用户lenson设置别名admin
testgroup: lenson,user1 实现群发 发给testgroup的邮件发给lenson 和user1以上2个可以分别测试
#newaliases
5,访问控制设置
更改/etc/mail/accesss文件,增加:
# cat /etc/mail/access
# Check the /usr/share/doc/sendmail/README.cf file for a description
# of the format of this file. (search for access_db in that file)
# The /usr/share/doc/sendmail/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
boway.edu RELAY
完成后makemap hash /etc/mail/access.db < /etc/mail/access进行数据库更新。
6,#service sendmail restart
# service sendmail restart 启动服务
Shutting down sendmail:
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
给lenson用户发邮件
# telnet boway.edu 25
220 boway.edu ESMTP Sendmail 8.13.1/8.13.1; Wed, 24 Oct 2007 15:56:56 +0800
helo boway
250 boway.edu Hello , pleased to meet you
mail from:administrator@ibm.com
250 2.1.0 administrator@ibm.com... Sender ok
rcpt to:lenson@boway.edu
250 2.1.5 lenson@boway.edu... Recipient ok
data
354 Enter mail, end with "." on a line by itself
hello lenson,this is a test,
i want to say The life is beautiful
.
250 2.0.0 l9O7uu7l004003 Message accepted for delivery
7,安装邮局服务
# rpm -ivh dovecot-0.99.11-2.EL4.1.i386.rpm --aid
# vi /etc/dovecot.conf在protocols = imap imaps 后添加pop3 pop3s
启动dovecot服务
# service dovecot restart
Stopping Dovecot Imap:
Starting Dovecot Imap: [ OK ]
# chkconfig --level 35 dovecot on
OK了 我们使用客户机测试。可以使用Outlook

[ 本帖最后由 lenson 于 2007-10-24 15:05 编辑 ]

lenson 发表于 2007-10-24 15:14:08

实现虚拟主机和虚拟邮件帐号

我们使用Sendmail的配置文件/etc/mail/sendmail.cw实现虚拟主机的功能,利用/etc/mail/virtusertable文件的设置实现虚拟邮件帐号的功能,并通过telnet客户端工具连接邮件服务器,发送邮件到虚拟主机和虚拟帐号进行测试。

1、继续使用上面试验建立的sendmail环境!
2、我们为本机再另外指定一个域名,如iso.com
3、使用vi命令编辑sendmail.cw   添加虚拟主机域名
   #vi /etc/mail/senmail.cw
   iso.com
4、使用vi命令编辑/etc/mail/virtusertable文件,为虚拟主机创建个虚拟邮件帐号viruser(这个帐
   号其实并不存在),使这个虚拟邮件用户的接受者实际是root用户,设置如下
   #vi /etc/mail/virtusertable
   viruser@iso.com                  root
5、使用makemap命令更新虚拟邮件帐号库
   #makemap hash /etc/mail/virtusertable.db < /etc/mail/virtusertable
6、重启服务,然后在客户端使用telnet连接到虚拟主机邮件服务器的25端口,然后给虚拟邮件帐
    号发送邮件,查看root能否收到!
OK! 搞定!~

qinge 发表于 2007-12-7 16:05:35

受到,谢谢
楼主辛苦了
页: [1]
查看完整版本: 架设sendmail服务器