分类: LINUX
2013-12-20 16:11:19
1.检查是否安装了sendmail
[root@sendmail ~]# rpm -qa | grep sendmail
sendmail-8.13.8-8.el5
通过上面查询,看到默认安装包不全,配置yum安装所需包
2.配置yum,略。
3.yum安装
[root@sendmail ~]# yum install sendmail*
Installing:
sendmail-cf x86_64 8.13.8-8.el5 rhel-debuginfo 306 k
sendmail-devel i386 8.13.8-8.el5 rhel-debuginfo 128 k
sendmail-devel x86_64 8.13.8-8.el5 rhel-debuginfo 133 k
sendmail-doc x86_64 8.13.8-8.el5 rhel-debuginfo 665 k
4.再次检查安装结果
[root@sendmail ~]# rpm -qa | grep sendmail
sendmail-cf-8.13.8-8.el5
sendmail-doc-8.13.8-8.el5
sendmail-8.13.8-8.el5
sendmail-devel-8.13.8-8.el5
sendmail-devel-8.13.8-8.el5
5.开始配置sendmail文件-/etc/mail/sendmail.cf
[root@sendmail ~]# vi /etc/mail/sendmail.mc
修改116行
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
为
DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl
修改155行
155 LOCAL_DOMAIN(`localhost.localdomain')dnl
为
155 LOCAL_DOMAIN(`sendmail')dnl //此处的sendmail值为域名,建议设置为带.com标识
6.m4生成配置文件sendmail.cf
[root@sendmail ~]# m4 /etc/mail/sendmail.mc /etc/mail/sendmail.cf
7.修改local-host-names,设置可以接收邮件的主机
[root@sendmail mail]# vi local-host-names
修改后如下
# local-host-names - include all aliases for your machine here.
sendmail
保存,退出
8.修改ACCESS文件,设置允许使用的客户端
[root@sendmail /]# vi /etc/mail/access
修改之后如下
# by default we allow relaying from localhost...
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1 RELAY
Connect:qq.com RELAY
10.133.90 RELAY
9.重新生成access.db
[root@sendmail ~]# cd /etc/mail
[root@sendmail mail]# make access.db
10.安装imap,配置pop(dovecot套件)
[root@sendmail /]# yum -y install dovecot
11.查看hosts文件是否有解析
[root@sendmail /]# vi /etc/hosts
修改之后
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 sendmail localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.0.131 sendmail //此处如果域名和主机名不同,域名也需要写
12.重新启动各项服务
[root@sendmail /]# service sendmail restart
Shutting down sm-client: [ OK ]
Shutting down sendmail: [ OK ]
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
[root@sendmail /]# service dovecot restart
Stopping Dovecot Imap: [FAILED]
Starting Dovecot Imap: [ OK ]
[root@sendmail /]# service saslauthd restart
Stopping saslauthd: [FAILED]
Starting saslauthd: [ OK ]
将上面各项服务设置为开机启动
[root@sendmail /]# chkconfig sendmail on
[root@sendmail /]# chkconfig dovecot on
[root@sendmail /]# chkconfig saslauthd on
配置之后结果如下
[root@sendmail /]# chkconfig --list | grep sendmail
sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@sendmail /]# chkconfig --list | grep dovecot
dovecot 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@sendmail /]# chkconfig --list | grep saslauthd
saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
13.测试端口
telnet25端口测试截图
telnet 110端口截图
14.建立邮件测试账户,使用foxmail作为客户端进行收发邮件测试
[root@sendmail mail]# useradd sendmailtest
[root@sendmail mail]# passwd sendmailtest
Changing password for user sendmailtest.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
使用终端root账户发送消息给sendmailtest用户
[root@sendmail mail]# mail sendmailtest@sendmail
Subject: 这是一封测试邮件,由root发送
收到内容请回复
Cc:
[root@sendmail mail]#
[root@sendmail mail]#
之后登录foxmail,查看是否已经收到
可以看到刚刚由root发送出来的邮件,现回复一封邮件给root
点击发送之后,回到终端,按下回车,会看到有一条消息提示
You have new mail in /var/spool/mail/root
[root@sendmail mail]#
You have new mail in /var/spool/mail/root
[root@sendmail mail]#