postfix+squirrelmail - rhat 5.4

系统环境:

安装邮件服务器,postfix+squirrelmail+rhat 5.4下测试,本实验目的是,在服务器与客户端之间相互收发邮件和转发邮件;

 

 

  

  

服务器

客户端

RedHat 5.4

mail.163.com

172.16.1.253

172.16.1.10

所需安装包:

bind  (DNS)

postfix(邮件服务器)

DovecotPOP/IMAP协议,用于接受邮件)

Saslauthd(安全认证包)

Squirrelmail(基于web的邮件客户端)

1、配置IP

2、配置主机名:mail.163.com

[root@localhost ~]# vim /etc/sysconfig/network

HOSTNAME=mail.163.com

:wq  保存

[root@localhost ~]# hostname mail.163.com

断开终端,再次连接,这样就需要重新启动系统:ctrl+d

[root@mail ~]#

 

3、配置DNS文件

[root@mail ~]# vim /etc/resolv.conf

nameserver 172.16.1.253

 

4、配置hosts文件

[root@mail ~]# vim /etc/hosts 

127.0.0.1       mail.163.com

 

5、配置YUM

参照:

http://yanghuawu.blog.51cto.com/2638960/886129

6、安装DNS(bind)

[root@mail ~]# cd /mnt/Server/

[root@mail Server]# rpm -ivh bind-9.3.6-4.P1.el5.i386.rpm     

Preparing...                ########################################### [100%]

   1:bind                   ########################################### [100%]

[root@mail Server]# rpm -ivh bind-chroot-9.3.6-4.P1.el5.i386.rpm

Preparing...                ########################################### [100%]

   1:bind-chroot            ########################################### [100%]     

[root@mail Server]# rpm -ivh caching-nameserver-9.3.6-4.P1.el5.i386.rpm

Preparing...                ########################################### [100%]

   1:caching-nameserver     ########################################### [100%]  

 

[root@mail Server]# cd /var/named/chroot/etc/

[root@mail etc]# ll

total 32

-rw-r--r-- 1 root root   405 Dec 18 05:13 localtime

-rw-r----- 1 root named 1230 Jul 30  2009 named.caching-nameserver.conf

-rw-r----- 1 root named  955 Jul 30  2009 named.rfc1912.zones

-rw-r----- 1 root named  113 Dec 18 05:48 rndc.key

 

[root@mail etc]# cp -p named.caching-nameserver.conf named.conf

[root@mail etc]# vim named.conf    

修改:

 15         listen-on port 53 { any; };

 27         allow-query     { any; };

 28         allow-query-cache { any; };

 37         match-clients      { any; };

 38         match-destinations { any; };

wq

 

[root@mail etc]# vim named.rfc1912.zones  

 27 zone "163.com" IN {

 28         type master;

 29         file "163.com.zone";

 30         allow-update { none; };

 31 };

:wq

 

[root@mail etc]# cd ../var/named/

[root@mail named]# pwd

/var/named/chroot/var/named

[root@mail named]# cp -p localhost.zone 163.com.zone

[root@mail named]# vim 163.com.zone

$TTL    86400

@               IN SOA  ns.163.com.       root (

                                        42              ; serial (d. adams)

                                        3H              ; refresh

                                        15M             ; retry

                                        1W              ; expiry

                                        1D )            ; minimum

                IN NS           ns.163.com.

ns              IN A            172.16.1.253

mail            IN A            172.16.1.253

pop3            IN CNAME        mail

smtp            IN CNAME        mail

@               IN MX 10        mail

:wq

 

[root@mail named]# service named start

Starting named:                                            [  OK  ]

[root@mail named]# service named restart

Stopping named:                                            [  OK  ]

Starting named:                                            [  OK  ]

[root@mail named]#

 

[root@mail named]# rndc reload

server reload successful

[root@mail named]# dig -t mx 163.com

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5 <<>> -t mx 163.com

;; global options:  printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10922

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

;; QUESTION SECTION:

;163.com.                       IN      MX

;; ANSWER SECTION:

163.com.                86400   IN      MX      10 mail.163.com.

;; AUTHORITY SECTION:

163.com.                86400   IN      NS      ns.163.com.

;; ADDITIONAL SECTION:

mail.163.com.           86400   IN      A       172.16.1.253

ns.163.com.             86400   IN      A       172.16.1.253

 

;; Query time: 5 msec

;; SERVER: 172.16.1.253#53(172.16.1.253)

;; WHEN: Tue Dec 18 06:12:41 2012

;; MSG SIZE  rcvd: 95

 

[root@mail named]# chkconfig named on

 

确认sendmail是否已关闭,并不随机启动或者卸载

[root@mail named]# service sendmail status

sendmail (pid  2754) is running...

[root@mail named]# service sendmail stop

Shutting down sm-client:                                   [  OK  ]

Shutting down sendmail:                                    [  OK  ]

[root@mail named]# chkconfig sendmail off

[root@mail named]#

 

7、安装postfix

[root@mail named]# cd /mnt/Server/

[root@mail Server]# ll postfix*

-r--r--r-- 278 root root 3734257 Aug 14  2008 postfix-2.3.3-2.1.el5_2.i386.rpm

-r--r--r-- 278 root root   51012 Aug 14  2008 postfix-pflogsumm-2.3.3-2.1.el5_2.i386.rpm

[root@mail Server]# rpm -ivh postfix-2.3.3-2.1.el5_2.i386.rpm

Preparing...                ########################################### [100%]

   1:postfix                ########################################### [100%]

[root@mail Server]# vim /etc/postfix/main.cf

69 #myhostname = host.domain.tld

修改

69 myhostname = mail.163.com  #本机名

 

77 #mydomain = domain.tld   

修改:

77 mydomain = 163.com         #域名

 

93 #myorigin = $mydomain

修改为

93 myorigin = $mydomain

 

107 #inet_interfaces = all

修改为

107 inet_interfaces = all

 

110 inet_interfaces = localhost

修改为

110 #inet_interfaces = localhost

 

155 mydestination = $myhostname, localhost.$mydomain, localhost

修改为

155 #mydestination = $myhostname, localhost.$mydomain, localhost

 

156 #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

修改为

156 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

 

255 #mynetworks = 168.100.189.0/28, 127.0.0.0/8

修改为

255 mynetworks = 127.0.0.0/8     #提供邮件转发功能的网段

 

255 mynetworks = 127.0.0.0/8上面添加如下:#使用SMTP认证

broken_sasl_auth_clients = yes

smtpd_sasl_auth_enable = yes

smtpd_sasl_security_options = noanonymous

smtpd_sasl_application_name = smtpd

smtpd_client_restrictions = permit_sasl_authenticated,reject

#smtpd_clietn_restrictions = permit_sasl_authenticated

smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated, reject_unauth_destination

262 mynetworks = 127.0.0.0/8

:wq

 

[root@mail Server]# service saslauthd start

Starting saslauthd:                                        [  OK  ]

[root@mail Server]# chkconfig saslauthd  on

[root@mail Server]# service postfix start

Starting postfix:                                          [  OK  ]

[root@mail Server]# service postfix restart

Shutting down postfix:                                     [  OK  ]

Starting postfix:                                          [  OK  ]

 

[root@mail Server]# netstat -tupln |less

tcp    0   0 0.0.0.0:25    0.0.0.0:*   LISTEN    4235/master

 

8、创建用户

[root@mail Server]# useradd user1

[root@mail Server]# useradd user2

[root@mail Server]# useradd user3

[root@mail Server]# passwd user1

Changing password for user user1.

New UNIX password:

BAD PASSWORD: it does not contain enough DIFFERENT characters

Retype new UNIX password:

passwd: all authentication tokens updated successfully.

[root@mail Server]# passwd user2

Changing password for user user2.

New UNIX password:

BAD PASSWORD: it does not contain enough DIFFERENT characters

Retype new UNIX password:

passwd: all authentication tokens updated successfully.

[root@mail Server]# passwd user3

Changing password for user user3.

New UNIX password:

BAD PASSWORD: it does not contain enough DIFFERENT characters

Retype new UNIX password:

passwd: all authentication tokens updated successfully.

 

9、安装squirrelmail(图形化邮件客户端)

[root@mail Server]# yum install squirrelmail

 

[root@mail Server]# service httpd restart

Stopping httpd:                                            [  OK  ]

Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using mail.163.com for ServerName

                                                           [  OK  ]

[root@mail Server]# chkconfig httpd on

[root@mail Server]# rpm -ql squirrelmail

[root@mail Server]# cd /var/www/html/

[root@mail html]# ln -s /usr/share/squirrelmail/ mail

[root@mail html]# ll

total 4

lrwxrwxrwx 1 root root 24 Dec 18 06:46 mail -> /usr/share/squirrelmail/

[root@mail html]# cd mail/

[root@mail mail]# ll

total 88

drwxr-xr-x  5 root root 4096 Dec 18 06:42 class

drwxr-xr-x  2 root root 4096 Dec 18 06:42 config

drwxr-xr-x  4 root root 4096 Dec 18 06:42 functions

drwxr-xr-x 30 root root 4096 Dec 18 06:42 help

drwxr-xr-x  2 root root 4096 Dec 18 06:42 images

drwxr-xr-x  3 root root 4096 Dec 18 06:42 include

-rw-r--r--  1 root root  684 May 21  2009 index.php

drwxr-xr-x 47 root root 4096 Dec 18 06:42 locale

drwxr-xr-x 18 root root 4096 Dec 18 06:42 plugins

drwxr-xr-x  2 root root 4096 Dec 18 06:42 src

drwxr-xr-x  3 root root 4096 Dec 18 06:42 themes

[root@mail mail]# cd config/

[root@mail config]# ll

total 204

-rw-r--r-- 1 root root  29548 May 21  2009 config_default.php

lrwxrwxrwx 1 root root     45 Dec 18 06:42 config_local.php -> ../../../../etc/squirrelmail/config_local.php

lrwxrwxrwx 1 root root     39 Dec 18 06:42 config.php -> ../../../../etc/squirrelmail/config.php

-rwxr-xr-x 1 root root 145648 May 21  2009 conf.pl

-rw-r--r-- 1 root root    492 May 21  2009 index.php

 

打开squirrelmail配置工具

[root@mail config]# ./conf.pl [root@mail ~]# /usr/share/squirrelmail/config/conf.pl

SquirrelMail Configuration : Read: config.php (1.4.0)

---------------------------------------------------------

Main Menu --

1.  Organization Preferences

2.  Server Settings

3.  Folder Defaults

4.  General Options

5.  Themes

6.  Address Books

7.  Message of the Day (MOTD)

8.  Plugins

9.  Database

10. Languages

 

D.  Set pre-defined settings for specific IMAP servers

C   Turn color off

S   Save data

Q   Quit

 

Command >> 10

 

      输入d,然后输入cyrus(指定IMAP服务器类型)

      输入2.  选择Server Settings然后输入1修改Domainmail.163.com

                                         3修改Sendmail or SMTP为选2--SMTP

      输入4.  选择General Options然后输入5修改Usernames in Lowercase : true

      输入10  选择Languages然后输入1修改Default Language : zh_CN

                                   2修改Default charset  : GB2312  

                                   R返回上一层    

      最后输入s保存以上修改,再输入q退出(修改的文件同时保存)

 

[root@mail config]# vim /etc/httpd/conf/httpd.conf

747 AddDefaultCharset UTF-8

修改为:

747 #AddDefaultCharset UTF-8

:wq

[root@mail config]# service httpd restart

 

10、网页访问:http://172.16.1.253/mail

用户登陆报错

系统出错

连接IMAP服务器出现错误:localhost

111 : 鎷掔粷杩炴帴

解决方法

[root@mail config]# yum install dovecot    #用于接受邮件

[root@mail config]# service dovecot restart

重新登录:OK

 

发邮件报错

系统出错:

Transaction failed

Server replied: 554 5.7.1 <localhost.localdomain[127.0.0.1]>: Client host rejected: Access denied

解决方法:

[root@mail config]# vim /etc/postfix/main.cf

smtpd_client_restrictions = permit_sasl_authenticated,reject

修改为

#smtpd_client_restrictions = permit_sasl_authenticated,reject

:wq

[root@mail config]# service postfix restart

 

11、查看收发邮件日志

[root@mail config]# tail -f /var/log/maillog

 




本文转自 yhw85 51CTO博客,原文链接:http://blog.51cto.com/yanghuawu/1092891,如需转载请自行联系原作者

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值