Postfix+Dovecot+ Postfixadmin+squirrelmail+Mysql安装「终于解决」

Postfix+Dovecot+ Postfixadmin+squirrelmail+Mysql安装「终于解决」Normal07.8磅02falsefalsefalseMicrosoftInternetExplorer4

大家好,欢迎来到IT知识分享网。

说明:我安装的时候也很挠头,橡皮树老师的视频帮助我很多。附上 link

http://www.freeboba.com/viewthread.php?tid=1313

 

一、安装环境

Redhat 4  Linux 2.6.9-34   i686 i686 i386 GNU/Linux

二、所需要的软件包

[root@localhost ~]# ls –lhrt

cyrus-sasl-2.1.23.tar.gz

dovecot-1.2.8.tar.gz

httpd-2.2.11.tar.gz

libc-client-2002e-14.i386.rpm

libc-client-devel-2002e-14.i386.rpm

mysql5.1.35.tar.gz

php-5.2.8.tar.gz

postfix-2.4.11.tar.gz

postfixadmin-2.3.tar.gz

squirrelmail-1.4.20-RC2.tar.bz2

 

三、开始安装

1 、安装之前要停掉 sendmail 服务

[root@localhost ~]# service sendmail stop

关闭 sm-client                                            [ 确定 ]

关闭 sendmail                                            [ 确定 ]

[root@localhost ~]# chkconfig sendmail off

 

2 、修改 /etc/hosts /etc/sysconfig/network

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

 

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1               localhost.localdomain localhost

::1              localhost6.localdomain6 localhost6

192.168.1.210          mail.mediawoz.cn mail

192.168.1.210          mediawoz.cn mail

 

注:以上红色字体可以改为你的外网 IP

 

 

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

 

NETWORKING=yes

NETWORKING_IPV6=yes

HOSTNAME=mail.mediawoz.cn

GATEWAY=192.168.1.1

 

3 、安装 apache

[root@localhost ~]# tar xzvf httpd-2.2.11.tar.gz // 解压到当前目录

[root@localhost ~]# cd httpd-2.2.11          // 进入安装目录

[root@localhost httpd-2.2.11]# ./configure –prefix=/usr/local/apache /   // 指定安装目录

>–enable-rewrite=shared /   // 编译 rewrite_module 模块否则不能正常加载最新的 php 模块

>–enable-speling=shared // 同上

>–enable-module=so    // 编译模块    

[root@mail httpd-2.2.11]# make ; make install // 编译安装 apache

[root@mail httpd-2.2.11]# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd // 复制启动文件

[root@mail httpd-2.2.11]# /etc/init.d/httpd start    // 这样就可以启动了,够简单吧

 

打开你的网页浏览器去测试吧。 http://mail.mediawoz.cn/ 要是正常的话就可以显示 It works

 

4 、安装 mysql

[root@mail ~]# tar xzvf mysql-5.1.35.tar.gz           

[root@mail ~]# cd mysql-5.1.35                   // 进入安装目录

[root@mail mysql-5.1.35]# groupadd mysql    // 添加运行 mysql 的组

[root@mail mysql-5.1.35]# useradd -g mysql mysql   // 添加运行 mysql 的用户并加入到组

[root@mail mysql-5.1.35]#./configure –prefix=/usr/local/mysql –with-innodb   // 指定安装目录

[root@mail mysql-5.1.35]#make && make install              // 编译安装

[root@mail mysql-5.1.35]# cp support-files/my-medium.cnf   /etc/my.cnf // 复制配置文件

[root@mail mysql-5.1.35]# cp support-files/mysql.server   /etc/rc.d/init.d/mysqld // 复制启动脚本,这样比较方便管理

[root@mail mysql-5.0.24a]# chmod 700 /etc/rc.d/init.d/mysqld // 添加执行权限

[root@mail mysql-5.0.24a]# cd /usr/local/mysql          // 进入 sql 安装目录

[root@mail mysql]# bin/mysql_install_db –user=mysql   // 初始化 mysql

安全设置

[root@mail mysql]# chown -R root   .   // 修改文件所有者 . 注意对像为 /usr/local/mysql 目录。

[root@mail mysql]# chown -R mysql var // 当前目录下的 var 目录所有者改为 mysql

[root@mail mysql]# chgrp -R mysql .   // 当前目录下所有目录所有者组改为 mysql

最后权限看起来要是这样的

[root@mail mysql]# ll

total 80

drwxr-xr-x   2 root   mysql 4096 Sep 21 16:38 bin

drwxr-xr-x   3 root   mysql 4096 Sep 21 16:37 include

drwxr-xr-x   2 root   mysql 4096 Sep 21 16:37 info

drwxr-xr-x   3 root   mysql 4096 Sep 21 16:37 lib

drwxr-xr-x   2 root   mysql 4096 Sep 21 16:39 libexec

drwxr-xr-x   3 root   mysql 4096 Sep 21 16:38 man

drwxr-xr-x   7 root   mysql 4096 Sep 21 16:39 mysql-test

drwxr-xr-x   3 root   mysql 4096 Sep 21 16:38 share

drwxr-xr-x   5 root   mysql 4096 Sep 21 16:38 sql-bench

drwx——   5 mysql mysql 4096 Sep 22 14:39 var

测试 mysql

[root@mail mysql]# /usr/local/mysql/bin/mysqld_safe –user=mysql &     

************* OK ********************

   这步就是启动 mysql daemon

************************************

出现错误则 tail -f /usr/local/mysql/var/mail.medaiwoz.cn.err

socket: ‘/tmp/mysql.sock’  port: 3306  Source distribution

 

要是正常的话会显示 mysqld ended

现在可以用 /etc/init.d/mysqld start 来启动 mysql 了。

推荐设置:

因为我们是源码安装,有时安装其他关连软件的时候常提示找不到 ?? 文件,

我们可以把 mysql 的库文件的路径加到系统的 sehll 中,这样可以大大减少安装软件的错误。方法如下:

[root@mail mysql]# PATH=$PATH:/usr/local/mysql/bin

[root@mail mysql]# export PATH

[root@mail mysql]# echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf

[root@mail mysql]# ldconfig

 

为了方便的用 mysqladmin 命令来管理 mysql 我们来做个链接 ;

[root@mail mysql]#ln -s /usr/local/mysql/bin/mysql /sbin/mysql

[root@mail mysql]#ln -s /usr/local/mysql/bin/mysqladmin /sbin/mysqladmin

Mysql 默认安装的管理员是空口令,这个当然要改了。

[root@mail mysql]# mysqladmin –u root password   ‘ 新的 mysql 口令

默认的情况下 mysql 只能本地登陆不能从网络登陆,为了使用一些 windows 下的 mysql 管理工具,我们有必要增加一个管理员来远程连接到 mysql; (这一步做不做都可以)方法如下:

[root@mail mysql-5.0.24a]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.   Commands end with ; or /g.

Your MySQL connection id is 72 to server version: 5.0.24a-log

Type ‘help;’ or ‘/h’ for help. Type ‘/c’ to clear the buffer .

 

mysql>grant all on *.* to remoteadmin@’%’ identified by ‘ 远程管理员口令 ‘       **********  OK 一定要‘ 7890 (密码) *******

mysql>with grant option;

 

 

 

5 、安装 php

在安装 php 之前要检查 是否安装 libc-client libc-client-devel 软件包,这两个软件包包含有 php imap 模块需要调用的宏

[root@localhost ~]$ rpm –qa | grep libc-client

 

若没有安装则 找到和系统对应的 libc-client 软件包,

 

REDHAT 4 linux 2.6.9 需要

libc-client-2002e-14.i386.rpm

libc-client-devel-2002e-14.i386.rpm

 

[root@localhost ~]$ rpm -ivh libc-client-2002e-14.i386.rpm

[root@localhost ~]$ rpm -ivh libc-client-devel-2002e-14.i386.rpm

 

REDHAT 5 linux 2.6.18 x86­_64 则需要四个软件包

 

[root@localhost ~]$ rpm -ivh libc-client-2004g-2.2.1.i386.rpm

[root@localhost ~]$ rpm -ivh libc-client-2004g-2.2.1.x86_64.rpm

[root@localhost ~]$ rpm –ivh libc-client-devel-2004g-2.2.1.i386.rpm

[root@localhost ~]$ rpm –ivh libc-client-devel-2004g-2.2.1.x86_64.rpm

 

[root@mail ~]# tar xjvf php-5.2.8.tar.gz       

[root@mail ~]# cd php-5.2.8                 // 进入安装目录

[root@mail php-5.2.8]#

./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache/bin/apxs –with-zlib –with-mysql=/usr/local/mysql –enable-mbstring –enable-mbstring=all –enable-soap –with-xml –enable-sockets –with-gd –with-curl –with-imap=/usr/local/imap –with-imap-ssl –with-openssl –with-kerberos

[root@mail php-5.2.8]# make

[root@mail php-5.2.8]# make test

[root@mail php-5.2.8]# make install

[root@mail php-5.2.8]# cp php.ini-dist /usr/local/lib/php.ini           // 复制 php 配置文件

[root@mail php-5.2.8]# vim /usr/local/lib/php.ini

(修改 register_global=On

[root@mail php-5.2.8]# cat /usr/local/apache/conf/httpd.conf | grep libphp5.so // 是否加载模块

LoadModule php5_module        modules/libphp5.so

要是有结果返回的话,我们的 php 模块就已加载了。要是没有的话请用下面的命令加载。

[root@mail php-5.2.8]# echo “LoadModule php5_module        modules/libphp5.so” >> /usr/local/apache/conf/httpd.conf

[root@mail php-5.2.8]# vi /usr/local/apache/conf/httpd.conf

317 行左右加入这两行,让 apache 支持 php

AddType application/x-httpd-php .php .phtml

AddType application/x-httpd-php-source .phps

保存退出。

[root@mail php-5.2.8]# /usr/local/apache/bin/ apachectl –k restart

 

然后在 apache 默认的 DocumentRoot 下面

[root@localhost ~]# cd /usr/local/apache/htdocs

[root@localhost htdocs]# vim test.php

 

<?php

 

        phpinfo();

 

?>

保存退出。 在你的浏览器上 输入 http://mail.mediawoz.cn/test.php 应该会显示出 php 的所有模块。 php 结束!!!

 

注:至此以下 要每时每刻查看 /var/log/maillog 它可以告诉你很多错误信息

6 、安装 postfixadmin

 

[root@mail ~]# mkdir /var/www                    // 建立 postfixadmin 存放目录

[root@mail ~]#cd /var/www

[root@mail www]#   tar xzvf /root/postfixadmin-2.1.0.tgz // 解压到当前目录

[root@mail www]# ln -s postfixadmin-2.1.0/ postfixadmin // 做个连接

[root@mail www]# chown -R daemon:daemon postfixadmin-2.1.0/   // 修改所有者为 httpd 用户

[root@mail www]# cd postfixadmin

[root@mail postfixadmin]# chmod 640 admin/*.php    // 设置权限增加安全性

[root@mail postfixadmin]# chmod 640 images/*.png

[root@mail postfixadmin]# chmod 640 languages/*.lang

[root@mail postfixadmin]# chmod 640 templates/*.tpl

[root@mail postfixadmin]# chmod 640 users/*.php

 

[root@mail postfixadmin]# cp config.inc.php.sample config.inc.php // 复制配置文件

[root@mail postfixadmin]# vi config.inc.php

找这行 $CONF[‘default_language’] = ‘en’;

改为 $CONF[‘default_language’] = ‘cn’;             // postfixadmin 支持中文

找到 $CONF[‘domain_in_mailbox’] = ‘YES’;

改为 $CONF[‘domain_in_mailbox’] = ‘NO’;              // If you don’t want to have the domain in your mailbox set this to ‘NO’.

找到此行: $CONF[‘encrypt’] = (原为 ‘md5crypt’

改为 CONF[‘encrypt’] = ‘cleartext’;             // 明文存入 mysql

 

[root@mail postfixadmin]#

ln -s /var/www/postfixadmin-2.3   /usr/local/apache/htdocs/postfixadmin

[root@mail postfixadmin]#   vim /usr/local/apache/conf/httpd.conf     // apache 的配置

 

 

 

 

 

<Directory “/var/www/postfixadmin”>

    Options Indexes FollowSymLinks ExecCGI

    DirectoryIndex   index.php

   AllowOverride None

   AuthType Basic

   authname Private

   authuserfile /var/phpaccess/kerwin

   require valid-user

    Order allow,deny

    Allow from all

</Directory>

注意 kerwin 是我的密码档文件名。

[root@mail postfixadmin]# mkdir /var/phpaccess

[root@mail postfixadmin]# touch /var/phpaccess/kerwin

[root@mail postfixadmin]# cd /var/phpaccess/

[root@mail phpaccess]# /usr/local/apache/bin/htpasswd -c /var/phpaccess/kerwin jim   // 添加用户 jim   -c 清空文件在添加,若想增加用户 去掉 –c

New password:

Re-type new password:

Adding password for user jim

 

上面的 kerwin 文件 对以后的收发邮件的用户没有影响,可以不配置。

 

现在可以在浏览器上 输入 http://yourip/postfixadmin/ 可以在 setup.php 里设置密码以及添加管理员。添加好管理员之后,就可以用管理员身份来增加邮件的域名和用户了。相应的增加都会在 mysql 里有显示。

 

[root@mail phpaccess]#  mysql -u root -p

>use mysql

>select * from user;

> insert into user (host,user,password) values (‘localhost’,’postfix’,password(‘postfixadmin’));

> flush privillieges;( 显示 Query OK, 0 rows affected (0.01 sec) 时正确 )

>create database postfix;

> grant all privileges on postfix.* to postfix@localhost identified by ‘postfixadmin’;

>quit

 

 

 

[root@mail phpaccess]#  mysql –u root –p

> show databases;

显示

 

 

 

+——————–+

| Database       |

+——————–+

| information_schema |

| postfix            |

| test              |

+——————–+

3 rows in set (0.04 sec)    正确

>Aborted

 

7 、安装 cyrus-sasl-2.1.23

 

解压

[root@mail cyrus-sasl-2.1.23]# rpm -qa | grep cyr             // 查看是否安装了 cyrus

cyrus-sasl-2.1.19-5.EL4

cyrus-sasl-devel-2.1.19-5.EL4

cyrus-sasl-md5-2.1.19-5.EL4

cyrus-sasl-plain-2.1.19-5.EL4

[root@mail cyrus-sasl-2.1.23]#   mv /usr/lib/sasl /usr/lib/sasl.off ( 若是没有,可以不做 )

[root@mail cyrus-sasl-2.1.23]#   mv /usr/lib/sasl2 /usr/lib/sasl2.off

[root@mailcyrus-sasl-2.1.23]#

./configure –enable-login –enable-sql –with-mysql=/usr/local/mysql/

[root@mailcyrus-sasl-2.1.23]# make && make install

安装后提示

********************************************************

* WARNING:

* Plugins are being installed into /usr/local/lib/sasl2,

* but the library will look for them in /usr/lib/sasl2.

* You need to make sure that the plugins will eventually

* be in /usr/lib/sasl2

所以要做个 ln

ln -s /usr/local/lib/sasl2 /usr/lib/sasl2

为了让 postfix 找到 sasl

[root@mail cyrus-sasl-2.1.23]# echo “/usr/local/lib” >> /etc/ld.so.conf

[root@mail cyrus-sasl-2.1.23]#  ldconfig

至此安装完毕

 

8 postfix 的安装

 

删除原来的 sendmail

[root@mail postfix-2.4.11]# /etc/init.d/sendmail stop

[root@mail postfix-2.4.11]# chkconfig –level 0123456 sendmail off

[root@mail postfix-2.4.11]# mv /usr/bin/newaliases /usr/bin/newaliases.orig

[root@mail postfix-2.4.11]# mv /usr/bin/mailq /usr/bin/mailq.orig

[root@mail postfix-2.4.11]# mv /usr/sbin/sendmail /usr/sbin/sendmail.orig

[root@mail postfix-2.4.11]#chkconfig –level 3 sendmail off

要开始安装我们的 postfix

[root@mail postfix-2.4.11]# groupadd -g 12345 postfix  <************* 如果原来有 大可以用原来的   大概 uid = 89  gid = 89 ***********************************>

[root@mail postfix-2.4.11]# useradd -u 12345 -g 12345 -c postfix -d /dev/null -s /bin/false   postfix

[root@mail postfix-2.4.11]# groupadd -g 54321 postdrop    <************ 原系统可能也会有   大概 gid = 90 ***************************>

验证 postfix 用户的 uid gid

[root@mail postfix-2.4.11]# id postfix

uid=12345(postfix) gid=12345(postfix) groups=12345(postfix)

准备加入 mysql sasl 的支持(注意 rpm 安装的 postfix 默认是不支持 mysql 的)

[root@mail postfix-2.4.11]#

make -f Makefile.init makefiles /                     

>’CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/include/sasl’   /

>’AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/local/lib -lsasl2′

<********* 若编译不通过 重新做上一步吧 ************>

[root@mail postfix-2.4.11]#make install  // 安装 mysql ,然后有提示的时候一路确定即可

如果 /etc/aliases 文件不存在,请用如下命令创建:

[root@mail postfix-2.4.11]# echo postfix: root >>/etc/aliases

[root@mail postfix-2.4.11]# /usr/bin/newaliases

然后我们可以用 postfix start 来启动 postfix 了,用 postfix reload 来得新加载配置文件 ;

[root@mail postfix-2.3.3]# cd /etc/postfix

[root@mail postfix]# vi main.cf  // 你可以先备份一下配置文件

 

配置文件 postfix/main.cf

 

#==========================BASE====================

myhostname = mail.mediawoz.cn

mydomain = mediawoz.cn

myorigin = $mydomain

mynetworks = 222.35.138.0/24 127.0.0.0/8 192.168.1.0/24

#mydestination = $myhostname $mydomain localhost localhost.$mydomain 222.35.138.43

#mydestination = $myhostname $mydomain  // 我们可以都注释掉,用默认的

inet_interface = all

 

alias_maps=hash:/etc/aliases

alias_database=hash:/etc/aliases

 

#==========================Vritual Mailbox settings =====

 

 

virtual_mailbox_base = /var/mailbox

virtual_mailbox_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_maps.cf

virtual_mailbox_domains = mysql:/etc/postfix/mysql/mysql_virtual_domains_maps.cf

virtual_alias_domains =

virtual_alias_maps = mysql:/etc/postfix/mysql/mysql_virtual_alias_maps.cf

virtual_uid_maps = static:12345

virtual_gid_maps = static:12345

virtual_transport = virtual

# 红色字体注意路径

maildrop_destination_recipient_limit = 1

maildrop_destination_concurrency_limit = 1

 

#========================QUOTA===========================

message_size_limit = 52428800

mailbox_size_limit = 209715200

virtual_mailbox_limit = 209715200

virtual_create_maildirsize = yes

virtual_mailbox_extended = yes

virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf

virtual_mailbox_limit_override = yes

virtual_maildir_limit_message = Sorry, the user’s maildir has overdrawn his disk space quota, please try again later.

 

virtual_overquota_bounce = yes

 

#=============================SASL=======================

broken_sasl_auth_clients = yes

 

smtpd_banner = $myhostname ESMTP “Version not Available”

 

#smtpd_recipient_restrictions = permit_mynetworks, reject_invalid_hostname, reject_unknown_sender_domain, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_pipelining, reject_unauth_destination, permit

 

smtpd_sasl_path = /var/run/dovecot/auth-client

smtpd_sasl_local_domain = $myhostname

smtpd_sasl_type = dovecot

smtpd_sasl_security_options = noanonymous

######

#smtpd_sasl_application_name = smtpd 

#// you can delete it , if have it ,we can not send mail ,  Relay access denied;

#####

 

smtpd_client_restrictions = permit_sasl_authenticated

smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination

smtpd_sasl_auth_enable = yes

 

#relay_domains = $mydestination

readme_directory = no

sample_directory = /etc/postfix

sendmail_path = /usr/sbin/sendmail

html_directory = no

setgid_group = postdrop

command_directory = /usr/sbin

manpage_directory = /usr/local/man

daemon_directory = /usr/libexec/postfix

 

[root@mail postfix]#cd   /etc/postfix/mysql

[root@mail mysql]#vi mysql_virtual_alias_maps.cf

user = postfix

password = postfix

hosts = localhost

dbname = postfix

query = SELECT goto FROM alias WHERE address=’%s’ AND active = 1

[root@mail mysql]#vi mysql_virtual_domains_maps.cf

user = postfix

password = postfixadmin

hosts = localhost

dbname = postfix

table = domain

select_field = domain

where_field = domain

additional_conditions = AND active = ‘1’

[root@mail mysql]#vi mysql_virtual_mailbox_maps.cf

user = postfix

password = postfix

hosts = localhost

dbname = postfix

query = SELECT maildir FROM mailbox WHERE username=’%s’ AND active = 1

[root@mail mysql]#vi   mysql_virtual_mailbox_limit_maps.cf

user = postfix

password = postfix

hosts = localhost

dbname = postfix

query = SELECT quota FROM mailbox WHERE username=’%s’

 

 

 

[root@mail mysql]# cd ..

[root@mail postfix]# vim master.cf

配置文件 postfix/master.cf

 

#

# Postfix master process configuration file.  For details on the format

# of the file, see the master(5) manual page (command: “man 5 master”).

#

#=====================================================================

# service type  private unpriv  chroot  wakeup  maxproc command + args

#               (yes)   (yes)   (yes)   (never) (100)

#=====================================================================

smtp      inet  n       –       n       –       –       smtpd

#submission inet n       –       n       –       –       smtpd

#  -o smtpd_enforce_tls=yes

#  -o smtpd_sasl_auth_enable=yes

#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

#smtps     inet  n       –       n       –       –       smtpd

#  -o smtpd_tls_wrappermode=yes

#  -o smtpd_sasl_auth_enable=yes

#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

#628      inet  n       –       n       –       –       qmqpd

pickup    fifo  n       –       n       60      1       pickup

cleanup   unix   n       –       n       –       0       cleanup

qmgr      fifo  n       –       n       300     1       qmgr

#qmgr     fifo  n       –       n       300     1       oqmgr

tlsmgr    unix  –       –       n       1000?   1       tlsmgr

rewrite   unix  –        –       n       –       –       trivial-rewrite

bounce    unix  –       –       n       –       0       bounce

defer     unix  –       –       n       –       0       bounce

trace     unix  –       –       n       –       0       bounce

verify    unix  –       –       n       –       1       verify

flush     unix  n       –       n       1000?   0       flush

proxymap  unix  –       –       n       –       –       proxymap

smtp      unix  –       –       n       –       –       smtp

# When relaying mail as backup MX, disable fallback_relay to avoid MX loops

relay     unix  –       –       n       –       –       smtp

       -o fallback_relay=

#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5

showq     unix  n       –       n       –       –       showq

error     unix  –       –       n       –       –       error

retry     unix  –       –       n       –       –       error

discard   unix  –       –       n       –       –       discard

local     unix  –       n       n       –       –       local

virtual   unix  –       n       n       –       –       virtual

lmtp      unix  –       –       n       –       –       lmtp

anvil     unix  –       –       n       –       1       anvil

scache      unix     –      –      n     –      1     scache

#

# ====================================================================

# Interfaces to non-Postfix software. Be sure to examine the manual

# pages of the non-Postfix software to find out what options it wants.

#

# Many of the following services use the Postfix pipe(8) delivery

# agent.  See the pipe(8) man page for information about ${recipient}

# and other message envelope options.

# ====================================================================

#

# maildrop. See the Postfix MAILDROP_README file for details.

# Also specify in main.cf: maildrop_destination_recipient_limit=1

#

maildrop  unix  –       n       n       –       –       pipe

  flags=DRhu user=postfix argv=/usr/local/bin/maildrop -d ${recipient}

#

# ====================================================================

#

# The Cyrus deliver program has changed incompatibly, multiple times.

#

#old-cyrus unix  –       n       n       –       –       pipe

#  flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}

#

# ====================================================================

#

# Cyrus 2.1.5 (Amos Gouaux)

# Also specify in main.cf: cyrus_destination_recipient_limit=1

#

#cyrus     unix  –       n       n       –       –       pipe

#  user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}

#

# ====================================================================

#

# See the Postfix UUCP_README file for configuration details.

#

#uucp      unix  –       n       n       –       –       pipe

#  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender – $nexthop!rmail ($recipient)

#

# ====================================================================

#

# Other external delivery methods.

#

#ifmail    unix  –       n       n       –       –       pipe

#  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)

#

#bsmtp     unix  –       n       n       –       –       pipe

#  flags=Fq. user=bsmtp argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient

#

#scalemail-backend unix –       n       n       –       2       pipe

#  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store

#  ${nexthop} ${user} ${extension}

#

#mailman   unix  –       n       n       –       –       pipe

#  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py

#  ${nexthop} ${user}

 

 

 

[root@mail postfix]# chown -R postfix:postfix   /var/mailbox

[root@mail postfix]# vi /usr/local/lib/sasl2/smtpd.conf

pwcheck_method: auxprop

auxprop_plugin: sql

mech_list: plain login

sql_engine: mysql

sql_hostnames: localhost

sql_user: postfix

sql_passwd: postfixadmin

sql_database: postfix

sql_select: SELECT password FROM mailbox WHERE username=’%u@%r’ and domain=’%r’ and active=’1′ 记得保存退出

[root@mail postfix]# postfix reload

[root@mail postfix]# postfix stop

[root@mail postfix]# postfix start

 

现在我们启动我们的 postfix 测度 postfix

 

[root@mail postfix]# telnet mail.mediawoz.cn 25

 

Trying 127.0.0.1…

Connected to localhost.localdomain.

Escape character is ‘^]’.

220 mail.mediawoz.cn ESMTP Postfix (Ubuntu)

ehlo mediawoz.com 

250-mail.mediawoz.cn

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-STARTTLS

250-AUTH LOGIN PLAIN

250-AUTH=LOGIN PLAIN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

mail from: user@mediawoz.cn

250 2.1.0 Ok

rcpt to: user@163.com

250 2.1.5 Ok

data

354 End data with <CR><LF>.<CR><LF>

 

Subject:  Test_lamp_20080523  

 

This is a test

.               // 此处有点才结束

250 2.0.0 Ok: queued as 365E2DF023C

quit

221 2.0.0 Bye

Connection closed by foreign host.

 

注: 红色字体为用户手动输入内容

 

 

9 、安装配置 dovecot

 

[root@mail dovecot-1.2.8]# ./configure   –with-mysql // 加入 sql 的支持

[root@mail dovecot-1.2.8]# useradd -d /dev/null -s /bin/false   dovecot   // 添加运行用户

[root@mail dovecot-1.2.8]#make && make install

安装就是这么简单,下面来复制配置所要的配置文件

[root@mail dovecot-1.2.8]# cp dovecot-example.conf   /usr/local/etc/dovecot.conf

[root@mail dovecot-1.2.8]# cd /usr/local/etc/

[root@mail etc]#vi dovecot.conf  

 

base_dir=/var/run/dovecot

protocols=imap  pop3

listen=*

disable_plaintext_auth = no

ssl = no

 

login_dir = /var/run/dovecot/login

login_chroot = yes

login_user = dovecot

login_process_size = 64

 

 

mail_location = maildir:/var/mailbox/ %d/%n/     # 注:此处的路径要与 postfix 配置一致

mail_uid=12345

mail_gid=12345

 

mail_debug = yes

 

first_valid_uid = 12345

#last_valid_uid = 0

 

protocol imap {

  

   listen=*

   login_executable = /usr/local/libexec/dovecot/imap-login

 

   mail_executable = /usr/local/libexec/dovecot/imap

   mail_plugin_dir = /usr/local/lib/dovecot/imap

   imap_logout_format = bytes=%i/%o

}

 

protocol pop3 {

   listen=*

   login_executable = /usr/local/libexec/dovecot/pop3-login

   mail_executable = /usr/local/libexec/dovecot/pop3

   pop3_no_flag_updates = no

   pop3_enable_last = no

 

#   pop3_uidl_format = %08Xu%08Xv

 

   pop3_uidl_format =%v.%u

 

   pop3_logout_format = top=%t/%p, retr=%r/%b, del=%d/%m, size=%s

 

   mail_plugin_dir = /usr/local/lib/dovecot/pop3

 

}

 

 

protocol lda {

  postmaster_address = root

 

  mail_plugin_dir = /usr/local/lib/dovecot/lda

  auth_socket_path = /var/run/dovecot/auth-master

  [color=Blue]mail_plugins = cmusieve quota [/color]

  log_path = /var/log/sieve.log

 

}

 

auth_executable = /usr/local/libexec/dovecot/dovecot-auth

auth_cache_ttl = 3600

auth_cache_negative_ttl = 3600

 

auth_default_realm = mediawoz.cn

auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@

 

auth_debug = yes

 

auth default {

  mechanisms = plain login #digest-md5 cram-md5

 

 

  passdb sql {

    args = /usr/local/etc/dovecot-sql.conf

  }

 

  userdb sql {

    args = /usr/local/etc/dovecot-sql.conf

  }

 

  socket listen {

      client {
   

              path = /var/run/dovecot/auth-client

              mode = 0660

              user = postfix

              group = postfix

             

       }

  }

}

 

 

dict {

  quota = mysql:/usr/local/etc/dovecot-dict-quota.conf

}

 

plugin {

#  quota = maildir

#  trash = /usr/local/etc/dovecot-trash.conf

}

 

最后我们配置一下 dovecot-sql.conf

[root@mail etc]# vi dovecot-sql.conf

 

driver = mysql

 

default_pass_scheme = PLAIN

#default_pass_scheme = CRYPT

 

connect = host=/tmp/mysql.sock dbname=postfix user=postfix password=postfixadmin

#default_pass_scheme = MD5

 

password_query = SELECT password FROM mailbox WHERE username = ‘%u’

user_query = SELECT maildir , 12345 AS uid, 12345 AS gid FROM mailbox WHERE username = ‘%u’

 

现在我们可以启动 dovecot 了。

[root@mail etc]# /usr/local/sbin/dovecot      // 启动 dovecot

 

要是报错可以 /var/log/maillog 看详细信息

[root@mail ~]# netstat -antp

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      3846/mysqld        

tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN      3913/dovecot       

tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN      3913/dovecot 

tcp        0      0 :::80                      :::*                        LISTEN      5494/httpd

tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      5468/master           // 这个是 postfix 监听的端口

 

[root@mail ~]# telnet mail.medidwoz.cn 110           

Trying 222.35.138.43…

Connected to mail.mediawoz.cn (222.35.138.43).

Escape character is ‘^]’.

+OK Dovecot ready.

user win@mediawoz.cn

+OK

pass win

+OK Logged in.

list

+OK 0 messages:

.

quit

+OK Logging out.

Connection closed by foreign host.

 

 

至此 我们基本的服务都配置完了。 现在你可以用 outlook 来测试了。

 

每次你在 postfixadmin 增加域或者用户名 密码都会在 mysql 里有显示。

 

[root@mail ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or /g.

Your MySQL connection id is 292

Server version: 5.1.35-log Source distribution

 

Type ‘help;’ or ‘/h’ for help. Type ‘/c’ to clear the current input statement.

mysql> use postfix;

Database changed

mysql> show tables;

mysql> select * from mailbox;

mysql>quit

 

10 webmail 安装

squirrelmail
是一个用
PHP
写成的,基于
IMAP
协议的
webmail
邮件系统。当前版本的功能已经十分完备,做个性化修改也很方便。它不用编译可以直接安装,但是要改几个参数。

 

[root@mail squirrelmail-1.4.20-RC2]# ls

class  config  configure  contrib  data  doc  functions  help  images  include  index.php  locale  plugins  po  README  src  themes

[root@mail squirrelmail-1.4.20-RC2]# ./configure

 

      

会出现以下画面:

#########################################################
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 on
S   
Save data
Q   
Quit
 
Command >>
#########################################################
 
      
1
、选择
1
,进入组织设置

#########################################################
Organization Preferences
1.    
Organization Name        
: SquirrelMail
         根据具体情况修改

2.    
Organization Logo        
: ../images/sm_logo.png
     根据具体情况修改

3.    
Org. Logo Width/Height : (308/111)
4.    
Organization Title       
: SquirrelMail $version
     根据具体情况修改

5.    
Signout Page             
: 
                根据具体情况修改

6.    
Top Frame                
: _top
7.    
Provider link            
: http://www.squirrelmail.org/
8.    
Provider name            
: SquirrelMail
#########################################################
 
      
2
、选择
2
,进入服务器选项

#########################################################
Server Settings
 
General
1.    
Domain                   
: mediawoz.cn
          改成自己的域名
domain
2.    
Invert Time              
: false
3.    
Sendmail or SMTP         
: SMTP
              建议改成
Sendmail
 
A.    
Update IMAP Settings     
: localhost:143 (cyrus)
     改成
(courier)
B.    
Update SMTP Settings     
: localhost:25
#########################################################
 
      
3
、选择
4
,进入全局设置

#########################################################
General Options
1.  
Data Directory               
: /var/local/squirrelmail/data/
2.  
Attachment Directory         
: /var/local/squirrelmail/attach/
3.  
Directory Hash Level         
: 0
4.  
Default Left Size            
: 150
5.  
Usernames in Lowercase       
: false
6.  
Allow use of priority        
: true
7.  
Hide SM attributions         
: false
8.  
Allow use of receipts        
: true
9.  
Allow editing of identity    
: true
    
Allow editing of name        
: true
    
Remove username from header  
: false
10. Allow server thread sort     
: false
11. Allow server-side sorting    
: false
12. Allow server charset search  
: true
13. Enable UID support           
: true
14. PHP session name             
: SQMSESSID
15. Location base                
: 
16. Only secure cookies if poss. : true
17. Disable secure forms         
: false
18. Page referal requirement     
: 
 
R   
Return to Main Menu
C  
 
Turn color on
S   
Save data
Q   
Quit
 
Command >>
#########################################################

10 选择语言  

#########################################################

Language preferences

1.  Default Language       : zh_CN

2.  Default Charset         : iso-8859-1

3.  Enable lossy encoding  : false

 

R   Return to Main Menu

C   Turn color on

S   Save data

Q   Quit

Command >> S       //  记得每一步都要保存 再返回

 

Data saved in config.php

Press enter to continue…

 

记得最后也要保存退出。

 

[root@mail ~]# cd /var/local/

[root@mail local]# cp ~/postfix/squirrelmail-1.4.20-RC2 . -r

[root@mail local]# ls

squirrelmail-1.4.20-RC2

[root@mail local]# mv squirrelmail-1.4.20-RC2 squirrelmail           

[root@mail local]# ls

squirrelmail

[root@mail local]# ls squirrelmail/

class  config  configure  contrib  data  doc  functions  help  images  include  index.php  locale  plugins  po  README  src  themes

[root@mail local]# ls squirrelmail/data/

default_pref  index.php

[root@mail squirrelmail]# chown -R apache:apache data   //apache 为你的 apache 运行名字及组名

[root@mail squirrelmail]# mkdir attach

[root@mail squirrelmail]# chown -R apache:apache attach/

[root@mail squirrelmail]# chmod 730 attach/

[root@mail squirrelmail]# chmod 730 data/ 

[root@mail squirrelmail]# chown -R apache:apache squirrelmail 

[root@mail squirrelmail]# ln -s /var/local/squirrelmail /usr/local/apache/htdocs/ squirrelmail

// 蓝色的路径为你的 apache  DocumentRoot  路径

[root@mail squirrelmail]# vi config/config.php

找到

$provider_uri     = ‘http://squirrelmail.org/”;

改为

$provider_uri      = ‘http://mail.mediawoz.cn /postfixadmin/users’;

注:蓝色字体为你的访问路径(域名或 IP 地址)

找到

$provider_name     = ‘SquirrelMail’

改为

$provider_name     = ‘change passwd’;       // 修改密码提示

注: 不知道为什么 明明语言改成了中文 zh_CN 但还是英文。

然后重启 apache

[root@mail squirrelmail]# /usr/local/apache/bin/apachectl -k restart

 

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/25747.html

(0)
上一篇 2023-07-07 20:00
下一篇 2023-07-16 09:00

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信