您的位置:首页 > 数据库 > MySQL

部署Postfix+MySQL+Dovecot+Postfixadmin+Extmail邮件系统(二)

2016-01-25 10:58 1011 查看


在第一次访问的过程中会在MySQL数据库,postfix库中添加相应的表结构,可以使用如下命令验证:
上面我们介绍了MySQL的查询表,接下来就来创建这个配置文件,看看文件中包含什么内容。

view sourceprint?

01.
[root@mail i386]
# cat /etc/postfix/mysql_virtual_alias_maps.cf

02.
user = postfix

03.
password = postfix

04.
hosts = localhost

05.
dbname = postfix

06.
table = 
alias

07.
select_field = goto

08.
where_field = address

09.
[root@mail i386]
#


mysql_virtual_domains_maps.cf配置文件内容:

 

view sourceprint?

01.
[root@mail i386]
# cat /etc/postfix/mysql_virtual_domains_maps.cf

02.
user = postfix

03.
password = postfix

04.
hosts = localhost

05.
dbname = postfix

06.
table = domain

07.
select_field = description

08.
where_field = domain

09.
[root@mail i386]
#


mysql_virtual_mailbox_limit_maps.cf配置文件内容:

 

view sourceprint?

01.
[root@mail i386]
# cat /etc/postfix/mysql_virtual_mailbox_limit_maps.cf

02.
user = postfix

03.
password = postfix

04.
hosts = localhost

05.
dbname = postfix

06.
table = mailbox

07.
select_field = 
quota

08.
where_field = username

09.
[root@mail i386]
#


mysql_virtual_mailbox_maps.cf配置文件内容:

 

view sourceprint?

01.
[root@mail i386]
# cat /etc/postfix/mysql_virtual_mailbox_maps.cf

02.
user = postfix

03.
password = postfix

04.
hosts = localhost

05.
dbname = postfix

06.
table = mailbox

07.
select_field = maildir

08.
where_field = username

09.
[root@mail i386]
#


Postfix的默认用户邮件存放目录是/var/spool/mail,由于RedHat默认设置的权限不是postfix用户本身,这里我们修改一下。笔者在搭建这个系统的过程中,由于这个目录导致使用Webmail登录不成功。当然我是如何发现的问题,通过看mail日志发现的这个问题。

 

view sourceprint?

1.
[root@mail i386]
# ls -ld /var/spool/mail/

2.
drwxrwxr-x 2 root mail 4096 Jan 19 00:07 /var/spool/mail/

3.
[root@mail i386]
# chown postfix.postfix
/var/spool/mail/

4.
[root@mail i386]
# ls -ld /var/spool/mail/

5.
drwxrwxr-x 2 postfix postfix 4096 Jan 19 00:07 /var/spool/mail/


四、            创建Postfix所需的数据库

hh

view sourceprint?

01.
[root@mail i386]
# mysql -u
root -p

02.
Enter password:

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

04.
Your MySQL connection 
id
 
is
3

05.
Server version: 5.0.77 Source distribution

06.
 
07.
Type 'help;' or '\h' 
for
 
help.
Type '\c' to 
clear
 
the buffer.

08.
 
09.
mysql&
gt
;
create database postfix;

10.
Query OK, 1 row affected (0.04 sec)

11.
 
12.
mysql&
gt
;
create user 'postfix'@'localhost' identified by 'postfix';

13.
Query OK, 0 rows affected (0.09 sec)

14.
 
15.
mysql&
gt
;
grant all privileges on postfix.* to postfix@'localhost';

16.
Query OK, 0 rows affected (0.03 sec)

17.
 
18.
mysql&
gt
;
flush privileges;

19.
Query OK, 0 rows affected (0.00 sec)


hh

 

view sourceprint?

01.
mysql&
gt
;
show databases;

02.
+--------------------+

03.
| Database                     |

04.
+--------------------+

05.
| information_schema |

06.
| mysql                            |

07.
| postfix                        |

08.
test
                             
|

09.
+--------------------+

10.
4 rows 
in
 
set
 
(0.29
sec)

11.
 
12.
mysql&
gt
;
use postfix;

13.
Database changed

14.
mysql&
gt
;
show tables;

15.
Empty 
set
 
(0.00
sec)

16.
 
17.
mysql&
gt
;
show grants 
for
 
postfix@'localhost';

18.
+---------------------------------------------------------------------------------------+

19.
| Grants 
for
 
postfix@localhost                                                         
|

20.
+---------------------------------------------------------------------------------------+

21.
| GRANT USAGE ON *.* TO 'postfix'@'localhost' IDENTIFIED BY PASSWORD '3ecf3e4f55dd846f'
|

22.
| GRANT ALL PRIVILEGES ON `postfix`.* TO 'postfix'@'localhost'                         
|

23.
+---------------------------------------------------------------------------------------+

24.
2 rows 
in
 
set
 
(0.00
sec)


五、Postfixadmin安装与配置

Postfixadmin是postfix邮件系统的web管理工具,可以通过它管理虚拟邮件主机、添加删除虚拟域、管理员、邮箱、别名以及用户等,配置工作十分简单。

安装Postfixadmin较简单,只要将该软件解压到Apache的主目录中即可。使用rpm包安装的Apache的默认路径在/var/www/html下。

 

view sourceprint?

1.
[root@mail ~]
# tar -zxvf postfixadmin-2.3.6.tar.gz
-C /var/www/html/

2.
… …

3.
postfixadmin-2.3.6/debian/control

4.
postfixadmin-2.3.6/debian/lighttpd.conf

5.
postfixadmin-2.3.6/debian/postfixadmin.docs

6.
postfixadmin-2.3.6/edit-domain.php

7.
[root@mail ~]
# cd /var/www/html/

8.
[root@mail html]
# mv postfixadmin-2.3.6
postfixadmin


接下来设置postfixadmin的配置文件config.inc.php,主要修改下面的参数项:

 

view sourceprint?

01.
[root@mail html]
# vim postfixadmin/config.inc.php

02.
……

03.
$CONF['configured'] = ture;      //将默认的
false
修改为ture

04.
$CONF['default_language'] = 'cn';            // postfixadmin默认语言:
"cn"
 
中文,
"en"
英文

05.
$CONF['database_type'] = 'mysql';    //数据库类型

06.
$CONF['database_host'] = 'localhost';  //数据库服务的位置

07.
$CONF['database_user'] = 'postfix';  //postfixadmin连接数据库时使用的用户名

08.
$CONF['database_password'] = 'postfix'; //访问数据库的密码

09.
$CONF['database_name'] = 'postfix';    //连接MySQL数据库的库名

10.
$CONF['smtp_server'] = 'localhost';

11.
$CONF['smtp_port'] = '25';

12.
$CONF['encrypt'] = 'md5crypt';      //数据库中密码的保存形式

13.
$CONF['domain_path'] = 'YES';      //指定以域名作为邮箱文件夹的路径名

14.
$CONF['domain_in_mailbox'] = 'NO';

15.
$CONF['aliases'] = '1000';

16.
$CONF['mailboxes'] = '1000';

17.
$CONF['maxquota'] = '1000';

18.
$CONF['
quota
']
= 'NO';

19.
// You can either use '1024000' or '1048576'

20.
$CONF['quota_multiplier'] = '1024000';        
#邮箱的大小限制


浏览器地址栏输入http://mail.xxx.com/postfixadmin/setup.php访问postfixadmin设置页,浏览器会出现如下图所示界面。

 



 

在第一次访问的过程中会在MySQL数据库,postfix库中添加相应的表结构,可以使用如下命令验证:

 

view sourceprint?

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

02.
Enter password:

03.
Welcome to the <a href=
"http://www.it165.net/database/dbmy/"
 
target=
"_blank"
class=
"keylink"
>MySQL</a>
monitor.    Commands end with ; or \g.

04.
Your MySQL connection 
id
 
is
156

05.
Server version: 5.0.77 Source distribution

06.
 
07.
Type 'help;' or '\h' 
for
 
help.
Type '\c' to 
clear
 
the buffer.

08.
 
09.
mysql&
gt
;
use postfix;

10.
Reading table information 
for
 
completion
of table and column names

11.
You can turn off this feature to get a quicker startup with -A

12.
 
13.
Database changed

14.
mysql&
gt
;
show tables;

15.
+-----------------------+

16.
| Tables_in_postfix         |

17.
+-----------------------+

18.
| admin                                 |

19.
alias
                                 
|

20.
| alias_domain                    |

21.
| config                                |

22.
| domain                                |

23.
| domain_admins                 |

24.
| fetchmail                         |

25.
| log                                     |

26.
| mailbox                             |

27.
quota
                                 
|

28.
| quota2                                |

29.
| vacation                            |

30.
| vacation_notification |

31.
+-----------------------+

32.
13 rows 
in
 
set
 
(0.00
sec)

33.
 
34.
mysql&
gt
;


在Change setup passwd下填写你要设置的密码后,将产生加密密码,如下所示:



 

按照提示,将产生的密码替换postfixadmin配置文件config.inc.php中$CONF['setup_password'] =’changeme”字段中的changeme,结果如下:

 

view sourceprint?

1.
$CONF['setup_pass<a href=
"http://www.it165.net/edu/ebg/"
 
target=
"_blank"
class=
"keylink"
>word</a>']
= ' dbd193530d798b7cd5d6f0a3805ee4e4:b5b951b8706bec173e58aeb38d333926caa3863c';


接下来创建Postfixadmin的管理员,Postfixadmin将管理员划分为两种:超级管理员和普通管理员,他们分别用以下用途:

超级管理员:可以添加删除邮件域、管理员;新建管理员并授予具有管理那个域的权限,新建用户邮箱等权限。

普通管理员:为了安全起见,一般情况下,使用超级管理员来创建邮件域和普通管理员,而使用普通管理员来添加用户邮箱以及别名。

在新版本中的postfixadmin管理工具中,在设置完Setup password后,就可以按照向导完成超级管理员的创建。

依次“创建输入Setup password密码、超级管理员用户名和密码”点击“新增”,如下图所示:

 



 
点击“新增”后,postfixadmin会提示“新增管理员成功”提示

 



 
超级管理员创建完成后,将setup.php文件和所有motd开头的txt文件,移动到其它位置,或者删除。

view sourceprint?

1.
[root@mail html]
# mv postfixadmin/setup.php
~

2.
[root@mail html]
# mv postfixadmin/motd*
~


创建完超级管理员后,我们直接输入http://mail.xxx.com/postfixadmin就可以使用超级管理员登录,完成邮件域和普通管理员的创建:

 



 

输入“超级管理员用户名和密码”点击“登录”完成登录。



 

接下来我们来以下面的信息为例来创建相应的信息:
 

域名
邮箱名
邮箱密码
xxx.com
yujinlong@xxx.com
123456
vfast.com
linken@vfast.com
123456
 
在创建域的过程中,只需要点击“域名清单”/“新建域”,如下所示:



 

输入域名的相关信息之后,点击“新增”即可。



 

点击“域名清单”,可以列出已创建的邮件域:



 
 
在创建普通管理员的过程中,和创建域的过程一样简单。只需要单击“管理员清单”/“新建管理员”



 
 
注意管理员名称输入的管理账号名为邮件地址,并赋予这个账号可以管理那些域,如果是多个域可以按Ctrl键,选中要选择的域的名称即可。之后点击“新增”



 
 
点击“管理员清单”可以看到有两个管理员,其中一个为超级管理员,另一个为普通管理员,管理的域名为2个。



 
创建完成后也可以登录到MySQL数据库中,查询admin表,你会发现这管理员的的信息。

view sourceprint?

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

02.
Enter password:

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

04.
Your MySQL connection 
id
 
is
135

05.
Server version: 5.0.77 Source distribution

06.
 
07.
Type 'help;' or '\h' 
for
 
help.
Type '\c' to 
clear
 
the buffer.

08.
 
09.
mysql&
gt
;
use postfix;

10.
Reading table information 
for
 
completion
of table and column names

11.
You can turn off this feature to get a quicker startup with -A

12.
 
13.
Database changed

14.
mysql&
gt
select
 
*
from admin;

15.
+------------------------+------------------------------------+---------------------+---------------------+--------+

16.
| username                             | password                                                    
| created                         | modified                        | active |

17.
+------------------------+------------------------------------+---------------------+---------------------+--------+

18.
| admin@xxx.com             | $1$4a6944be$g1JKJSJ8uEk.KtW.OBaKa. | 2013-01-21 22:41:50
| 2013-01-21 22:41:50 |            1 |

19.
| Super@postfixadmin.com | $1$7da3934e$/7Z5vzQmGXD3bVHFJGwu00 | 2013-01-21 22:36:31
| 2013-01-21 22:36:31 |            1 |

20.
+------------------------+------------------------------------+---------------------+---------------------+--------+

21.
2 rows 
in
 
set
 
(0.00
sec)

22.
 
23.
mysql&
gt
;


接下来使用我们创建的admin@xxx.com这个普通管理员登录Postfixadmin,完成用户邮箱的添加,同样是使用http://mail.xxx.com/postfixadmin这个管理链接来登录。

 



 

登录后,显示出了普通管理员能够完成的工作。



 

在创建用户邮箱的过程中,只需要点击“虚拟用户清单”/“新建邮箱”,如下所示:



 

输入用户名后选择用户要添加的邮件域名之后输入密码等信息,点击“增加邮箱”



 

完成后,会提示建立邮箱成功的提示,可以根据向导继续创建邮箱。



 

现在我们先测试一下Postfix服务是否能够启动,如果可以,并将其设置为开机自启动。 www.it165.net

 

view sourceprint?

1.
[root@mail ~]
# /etc/init.d/postfix
start

2.
Starting postfix:                                                                                   
[    OK    ]

3.
[root@mail ~]
# chkconfig --level
35 postfix on


通常,Postfix输出这一行信息并不能确认Postfix已经正常运行,我们还需要查看Postfix的系统日志中有没有什么出错信息。

 

view sourceprint?

1.
[root@mail ~]
# tail /var/log/maillog

2.
……

3.
Jan 22 02:57:49 mail postfix/postfix-script: starting the Postfix mail system

4.
Jan 22 02:57:49 mail postfix/master[27795]: daemon started -- version 2.3.3, configuration
/etc/postfix

5.
[root@mail ~]
#


如果日志文件中包含上面的两行信息,那么恭喜你了,现在Postfix已经能够启动了,虽然它还不能提供服务。继续努力吧!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: