postfix+mysql+courier+postfixadmin+Squirrelmail (自助)

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

postfix+mysql+courier+postfixadmin+Squirrelmail (自助)

#1

帖子 zhangfengsh » 2008-07-09 15:40

初装邮件系统,在这里发帖没人回应,自己找了些资料。
现将安装过程反映在本贴中,即给自己做个纪录,也希望对其他初装者有所帮助。

参考https://help.ubuntu.com/community/PostfixCompleteVirtualMailSystemHowto 搭建的。

mail.log中有这样的提示:
warning:SAS: authentication problem:unable to open Berkeley db /etc/sasldb2:No such file or dirctory

我使用的是MYSQL验证的,怎么会有这么个错误?

基本配置如下:
In /etc/courier/authdaemonrc
authmodulelist = "authmysql authpam"

smtpd.conf
pwcheck_method: auxprop
auxprop_plugin: sql
mech_list: plain login cram-md5 digest-md5
sql_engine: mysql
sql_hostnames: 127.0.0.1
sql_user: postfix
sql_passwd: aaaaaa
sql_database: postfix
sql_select: select passwd from mailbox where username='%u@%r' and active = 1

main.cf
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unknown_sender_domain, permit

smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_path = /etc/postfix/sasl:/usr/lib/sasl2
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain =

以前不使用mysql,使用Linix真是用户做邮件帐户时,是使用saslauthd验证的。
使用saslauthd验证的时候需访问/etc/sasldb2可以理解,怎么使用mysql的虚拟用户还要这个文件呢?

哪里少配置什么了?请给个提示


--------------------------------------------------------------------------------------------------------
补充:
该问题已解决,但又出现新问题。。。。(见21楼)
新问题为:SMTP不能通过验证,原因是用户密码在MySQL中以md5crypt方式加密,而SASL不支持加密,须打补丁。使用明文密码可收发信。(见25楼)

如须使用加密密码须对Cyrus-SASL打补丁。(见26楼)
上次由 zhangfengsh 在 2008-07-14 14:30,总共编辑 11 次。
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#2

帖子 zhangfengsh » 2008-07-09 18:39

查看mysql日志,发现发信时未查询数据库。

smtpd.conf没起作用???
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#3

帖子 zhangfengsh » 2008-07-09 18:45

在这种架构下,SMTP认证到底是使用的什么方式呢?不解。。。

libsasl2-modules-sql安装了。
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#4

帖子 zhangfengsh » 2008-07-09 18:53

查看/etc/log/auth.log 出现下面错误:

sql_select option missing
auxpropfunc error no mechanism available
_salsl_plugin_load failed on sasl_auxprop_plug_init for plugin:sql

是指smtpd.conf里的sql_select???
smtpd.conf里都已经设置了呀......
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#5

帖子 zhangfengsh » 2008-07-09 18:59

telnet localhost 25
.....
ehlo localhost
250-mail.xxxx.ccc
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-STATTLS
250-AUTH NTLM CRAM-MD5 LOGIN PLAIN DIGEST-MD5
250-AUTH=NTLM CRAM-MD5 LOGIN PLAIN DIGEST-MD5
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

这里似乎也有问题。AUTH NTLM CRAM-MD5 LOGIN PLAIN DIGEST-MD5
将smtpd.conf中的mech_list改为:mech_list:plain login
重启后,telnet 25时依然是AUTH NTLM CRAM-MD5 LOGIN PLAIN DIGEST-MD5
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#6

帖子 zhangfengsh » 2008-07-10 9:21

/var/log/auth.log

Jul 10 08:50:22 ubuntu postfix/smtpd[4762]: sql_select option missing
Jul 10 08:50:22 ubuntu postfix/smtpd[4762]: auxpropfunc error no mechanism available
Jul 10 08:50:22 ubuntu postfix/smtpd[4762]: _sasl_plugin_load failed on sasl_auxprop_plug_init for plugin: sql
Jul 10 08:50:22 ubuntu postfix/smtpd[4762]: NTLM server step 1
Jul 10 08:50:22 ubuntu postfix/smtpd[4762]: client flags: ffffb207
Jul 10 08:50:22 ubuntu postfix/smtpd[4762]: NTLM server step 2
Jul 10 08:50:22 ubuntu postfix/smtpd[4762]: client user: Myname Abc
Jul 10 08:50:22 ubuntu postfix/smtpd[4762]: client domain: Myname
Jul 10 08:50:22 ubuntu postfix/smtpd[4762]: NTLM server step 1
Jul 10 08:50:22 ubuntu postfix/smtpd[4762]: client flags: ffff8207
Jul 10 08:50:22 ubuntu postfix/smtpd[4762]: NTLM server step 2
Jul 10 08:50:22 ubuntu postfix/smtpd[4762]: client user: test1@abcdefg.com
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#7

帖子 zhangfengsh » 2008-07-10 13:11

没人理会.....

重新安装ubuntu 8.04 server。
仅安装LAMP。开启mysql log.

装完,apt-get update

居然遇到cn.ubuntu的源坏了,换了cn99的源继续安装。替换/etc/apt/source.list。

安装postfix.
apt-get install postfix
上次由 zhangfengsh 在 2008-07-10 13:26,总共编辑 2 次。
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#8

帖子 zhangfengsh » 2008-07-10 13:16

telnet localhost 25
220 ubuntu.mydomain.com ESMTP Postfix (Ubuntu)
ehlo localhost
250-ubunatu.mydomain.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
上次由 zhangfengsh 在 2008-07-10 15:34,总共编辑 4 次。
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#9

帖子 zhangfengsh » 2008-07-10 13:24

Intalling MySQL map support for postfix
安装postfix-mysql.
apt-get install postfix-mysql

版本为:2.5.1-2ubuntu

mysql-client ,mysql-server安装系统时已经自动安装。版本为5.0.51a
上次由 zhangfengsh 在 2008-07-10 15:27,总共编辑 1 次。
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#10

帖子 zhangfengsh » 2008-07-10 13:35

安装客户端访问和验证包

1. courier-authdaemon :Client Authentication.
2. courier-authlib-mysql : MySQL support for courier-authdaemo
3. courier-pop
4. courier-pop-ssl
5. courier-imap
6. courier-imap-ssl

apt-get install courier-authdaemon courier-authlib-mysql

apt-get install courier-pop courier-pop-ssl courier-imap courier-imap-ssl
上次由 zhangfengsh 在 2008-07-10 16:06,总共编辑 1 次。
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#11

帖子 zhangfengsh » 2008-07-10 13:46

安装完成后,mail.log中有:
authdaemond.plain: modules="authpam",daemons=5

telnet localhost 25
ehlo localhost

250-ubunatu.mydomain.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit

和安装前相同。
上次由 zhangfengsh 在 2008-07-10 13:57,总共编辑 1 次。
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#12

帖子 zhangfengsh » 2008-07-10 13:57

安装SMTP验证包

1. libsasl2 :Cyrus SASL Library
2. libsasl2-modules :Mechanisms
3. libsasl2-modules-sql : MySQL Support

apt-get install libsasl2 libsasl2-modules libsasl2-modules-sql
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#13

帖子 zhangfengsh » 2008-07-10 16:21

设置MySQL
mysql -uroot -p

1.创建数据库 posfix
mysql> CREATE DATABASE postfix;
mysql> USE postfix;


2,创建用户postfix,postfixadmin
mysql> GRANT SELECT ON postfix.* TO postfix@localhost IDENTIFIED BY 'postfixpassword';
mysql> GRANT SELECT, INSERT, DELETE, UPDATE ON postfix.* TO postfixadmin@localhost IDENTIFIED BY 'postfixadmin';


3 创建Admin表
CREATE TABLE admin (
username varchar(255) NOT NULL default '',
password varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (username),
KEY username (username)
) COMMENT='Postfix Admin - Virtual Admins';


4 创建Alias表
CREATE TABLE alias (
address varchar(255) NOT NULL default '',
goto text NOT NULL,
domain varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (address),
KEY address (address)
) COMMENT='Postfix Admin - Virtual Aliases';


5 创建Domain表
CREATE TABLE domain (
domain varchar(255) NOT NULL default '',
description varchar(255) NOT NULL default '',
aliases int(10) NOT NULL default '0',
mailboxes int(10) NOT NULL default '0',
maxquota int(10) NOT NULL default '0',
transport varchar(255) default NULL,
backupmx tinyint(1) NOT NULL default '0',
created datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (domain),
KEY domain (domain)
) COMMENT='Postfix Admin - Virtual Domains';


6 创建Domain Admin 表
CREATE TABLE domain_admins (
username varchar(255) NOT NULL default '',
domain varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
active tinyint(1) NOT NULL default '1',
KEY username (username)
) COMMENT='Postfix Admin - Domain Admins';


7 Mailbox
CREATE TABLE mailbox (
username varchar(255) NOT NULL default '',
password varchar(255) NOT NULL default '',
name varchar(255) NOT NULL default '',
maildir varchar(255) NOT NULL default '',
quota int(10) NOT NULL default '0',
domain varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (username),
KEY username (username)
) COMMENT='Postfix Admin - Virtual Mailboxes';


8 Log Table
CREATE TABLE log (
timestamp datetime NOT NULL default '0000-00-00 00:00:00',
username varchar(255) NOT NULL default '',
domain varchar(255) NOT NULL default '',
action varchar(255) NOT NULL default '',
data varchar(255) NOT NULL default '',
KEY timestamp (timestamp)
) COMMENT='Postfix Admin - Log';


9 Vacation Table
CREATE TABLE vacation (
email varchar(255) NOT NULL default '',
subject varchar(255) NOT NULL default '',
body text NOT NULL,
cache text NOT NULL,
domain varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (email),
KEY email (email)
) COMMENT='Postfix Admin - Virtual Vacation';
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#14

帖子 zhangfengsh » 2008-07-10 16:38

使用下面命令完成数据库初始。
mysql -uroot -p < DATABASE_MYSQL.TXT

DATABASE_MYSQL.TXT 内容

代码: 全选

CREATE DATABASE postfix;
USE postfix;
GRANT SELECT ON postfix.* TO postfix@localhost IDENTIFIED BY 'postfixpassword';
GRANT SELECT, INSERT, DELETE, UPDATE ON postfix.* TO postfixadmin@localhost IDENTIFIED BY 'postfixadmin';
CREATE TABLE admin (
  username varchar(255) NOT NULL default '',
  password varchar(255) NOT NULL default '',
  created datetime NOT NULL default '0000-00-00 00:00:00',
  modified datetime NOT NULL default '0000-00-00 00:00:00',
  active tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (username),
  KEY username (username)
) COMMENT='Postfix Admin - Virtual Admins';
CREATE TABLE alias (
  address varchar(255) NOT NULL default '',
  goto text NOT NULL,
  domain varchar(255) NOT NULL default '',
  created datetime NOT NULL default '0000-00-00 00:00:00',
  modified datetime NOT NULL default '0000-00-00 00:00:00',
  active tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (address),
  KEY address (address)
) COMMENT='Postfix Admin - Virtual Aliases';
CREATE TABLE domain (
  domain varchar(255) NOT NULL default '',
  description varchar(255) NOT NULL default '',
  aliases int(10) NOT NULL default '0',
  mailboxes int(10) NOT NULL default '0',
  maxquota int(10) NOT NULL default '0',
  transport varchar(255) default NULL,
  backupmx tinyint(1) NOT NULL default '0',
  created datetime NOT NULL default '0000-00-00 00:00:00',
  modified datetime NOT NULL default '0000-00-00 00:00:00',
  active tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (domain),
  KEY domain (domain)
) COMMENT='Postfix Admin - Virtual Domains';
CREATE TABLE domain_admins (
  username varchar(255) NOT NULL default '',
  domain varchar(255) NOT NULL default '',
  created datetime NOT NULL default '0000-00-00 00:00:00',
  active tinyint(1) NOT NULL default '1',
  KEY username (username)
) COMMENT='Postfix Admin - Domain Admins';
CREATE TABLE mailbox (
  username varchar(255) NOT NULL default '',
  password varchar(255) NOT NULL default '',
  name varchar(255) NOT NULL default '',
  maildir varchar(255) NOT NULL default '',
  quota int(10) NOT NULL default '0',
  domain varchar(255) NOT NULL default '',
  created datetime NOT NULL default '0000-00-00 00:00:00',
  modified datetime NOT NULL default '0000-00-00 00:00:00',
  active tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (username),
  KEY username (username)
) COMMENT='Postfix Admin - Virtual Mailboxes';
CREATE TABLE log (
  timestamp datetime NOT NULL default '0000-00-00 00:00:00',
  username varchar(255) NOT NULL default '',
  domain varchar(255) NOT NULL default '',
  action varchar(255) NOT NULL default '',
  data varchar(255) NOT NULL default '',
  KEY timestamp (timestamp)
) COMMENT='Postfix Admin - Log';
CREATE TABLE vacation (
  email varchar(255) NOT NULL default '',
  subject varchar(255) NOT NULL default '',
  body text NOT NULL,
  cache text NOT NULL,
  domain varchar(255) NOT NULL default '',
  created datetime NOT NULL default '0000-00-00 00:00:00',
  active tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (email),
  KEY email (email)
) COMMENT='Postfix Admin - Virtual Vacation';
上次由 zhangfengsh 在 2008-07-10 16:51,总共编辑 3 次。
zhangfengsh
帖子: 54
注册时间: 2008-07-08 14:41
送出感谢: 0
接收感谢: 0

#15

帖子 zhangfengsh » 2008-07-10 16:49

创建Postfix MySQL Maps

1 Virtual Alias Maps
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = alias
select_field = goto
where_field = address

2 Virtual Domain Maps
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = domain
select_field = domain
where_field = domain
#additional_conditions = and backupmx = '0' and active = '1'

3 Virtual Mailbox Maps
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = mailbox
select_field = maildir
where_field = username

4 Virtual Mailbox Quota Maps
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = mailbox
select_field = quota
where_field = username
#additional_conditions = and active = '1'

5 Relay Domain Maps
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = domain
select_field = domain
where_field = domain
additional_conditions = and backupmx = '1'


修改maps的权限:

sudo chgrp postfix /etc/postfix/mysql_*.cf
chmod 640 /etc/postfix/mysql_*.cf #只读

创建vmail用户

sudo groupadd -g 5000 vmail
sudo useradd -m -g vmail -u 5000 -d /home/vmail -s /bin/bash vmail
回复

回到 “服务器基础应用”