在DEBIAN 下安装POSTFIX 邮件系统
作者: 出处:网络整理 更新时间:2007-09-21 责任编辑:
 
 

二、安装软件
1、下载需要的软件
到www.extmail.org 下载extmail/extman/slockd ,通过FTP 上传到服务器,并解压

tar zxvf extmail-0\[1\].23-20060219.tar.gz

tar zxvf extman-0\[1\].15-20060518.tar.gz

tar zxvf slockd-0\[1\].08.tar.gz

2、安装mysql
mail:~# apt-get install mysql-server

安装完mysql 后,将extman 的数据导入到mysql 中

mail:/home/fy138# cd extman-0.15-20060518/docs

mail:/home/fy138/extman-0.15-20060518/docs# mysql -uroot <extmail.sql

打开extman-0.15-20060518/docs/init.sql 将里{crypt} 这些字符串删除,否则pop3可能无法登陆,如果你懒得去修改init.sql 可以安装完成后用phpmyadmin修改相关记录。

将uidnumber/gidnumber 改为postfix 的uid/gid 查看uid/gid 方法

mail:/etc/postfix# id postfix
uid=105(postfix) gid=106(postfix) groups=106(postfix)

mail:/home/fy138/extman-0.15-20060518/docs# mysql -uroot <init.sql

3、安装apache 2
mail:~# apt-get install apache2

4、安装php4
mail:~# apt-get install php4 php4-mysql libapache2-mod-php4 phpmyadmin

5、安装postfix
mail:~# apt-get install postfix postfix-mysql postfix-tls postfix-doc

在弹出的对话框中选择No configuration。

A、将extman目录下所有 mysql_virtul_*.cf 复制到/etc/postfix 目录下。

mail:~#cd /home/fy138/extman-0.15-20060518/docs

注意,这里我的存放位置是/home/fy138 ,不要照搬了。

mail:/home/fy138/extman-0.15-20060518/docs# cp mysql_virtual_*.cf /etc/postfix/

B、配置 /etc/postfix/main.cf,如果你的main.cf 已存先改名再重新编辑一个,加入下面的内容。

###################BASE##################myhostname=mail.extmail.org mydomain = extmail.orgmydestination = $myhostnamelocal_recipient_maps = smtpd_banner = extmail.org ESMTP Mail Systemmessage_size_limit = 14680064#################MySQL################virtual_gid_maps=static:106virtual_uid_maps=static:105virtual_transport = virtualvirtual_alias_maps =mysql:/etc/postfix/mysql_virtual_alias_maps.cfvirtual_mailbox_base = /home/data/domainsvirtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cfvirtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf################Quota################virtual_create_maildirsize = yesvirtual_mailbox_extended = yesvirtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cfvirtual_mailbox_limit_override = yesvirtual_maildir_limit_message = Sorry,the user's Maildir has overdrawn his diskspace quota ,please tray again later.virtual_overquota_bounce = yes##############SASL####################smtpd_sasl_auth_enable = yessmtpd_sasl2_auth_enable = yessmtpd_sasl_security_options = noanonymousbroken_sasl_auth_clients = yessmtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unauth_destination, reject_unauth_pipelining, reject_invalid_hostname, check_policy_service inet:127.0.0.1:10030
将 /etc/postfix/目录下面以mysql_virtul_*.cf 开头的文件,将里面的hosts=localhost 改为hosts=127.0.0.1 ,否则postfix 连接mysql 会出现问题 。

如果更改master.cf 将postfix 不以chroot 方式运行是否正常?还没有去试。

将/etc/postfix/master.cf中的下面几行把注释去掉

# only used by postfix-tlstlsmgr fifo - - n 300 1 tlsmgrsmtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes587 inet n - n - - smtpd -o smtpd_enforce_tls=yes -o smtpd_sasl_auth_enable=yes

6、安装cyrus-sasl2

mail:~# apt-get install libsasl2 libsasl2-modules libsasl2-modules-sql

创建/etc/postfix/sasl/smtpd.conf 加入下面的内容。

pwcheck_method:authdaemondlog_level:3mech_list:PLAIN LOGINauthdaemond_path:/var/run/courier/authdaemon/socket
注意:在进行smtpd 认证测试时,maillog 提示找不到 /var/run/courier/authdaemon/socket 通常是下面的问题 :1、权限 2、chroot 。

出错邮件日志:

May 20 17:35:26 mail postfix/smtpd[1229]: warning: SASL authentication failure: cannot connect to Courier authdaemond: No such file or directory


解决方法(引用wangpenghui 原文,Thanks! ^_^,本人使用了第二种方法,另外还要注意smtpd.conf文件中的空格!)

解决方法有如下两种,
1.对于postfix不做任何修改,而是在每次couier-authdaemon启动之后都创建

ln -f /var/run/courier/authdaemon/socket /var/spool/postfix/var/run/courier/authdaemon/socket

的硬链接. 同时对于

/var/run/courier/authdaemon/socket
/var/spool/postfix/var/run/courier/authdaemon/socket

的整个路径赋予postfix用户于读权限。一般为755.
2.第二种就是修改postfix中master.cf文件的如下行:

smtp inet n - - - - smtpd



smtp inet n - n - - smtpd

这样smtpd程序就不是运行在chroot状态,那么postfix的smtpd程序就可以通过smtpd.conf中的
authdaemond_path参数找到authdaemon的socket文件。不过也要注意权限问题,要不然就会出现connection refused的错误。这里指的权限是/var/run/courier/authdaemon/socket整个路径的权限,而不仅仅是socket文件的权限。

第二种方法相对于第一种方法来说,比较容易,但是增大了安全隐患。管理员可自行选择使用哪种方式。
当然,我这里也是抛砖引玉,肯定还有更好的解决办法。希望大家能够赐教。
参考:http://www.extmail.org/forum/archive/2/0605/1723.html

7、安装courier-imap
注意安装时,会提示你是否创建一个目录来放这些配置文件,要选择 YES 否则可能你的文件位置与下面配置的不一样。

mail:~# apt-get install courier-authdaemon courier-authmysql courier-base courier-imap courier-pop courier-pop-ssl courier-imap-ssl

A、配置courier-authdaemon ,autdaemon 是邮件系统认证的主要软件,很多人无法通过SMTPD认证多数问题在这里。

将/etc/courier/authdaemonrc 改名为 /etc/courier/authdaemonrc.bak

authmodulelist="authmysql"authmodulelistorig="authmysql"version="authdaemond.mysql"daemons=5authdaemover=/var/run/courier/authdaemonsubsystem=mailDEBUG_LOGIN=2DEFAULTOPTIONS="wbnodsn=1"
将/etc/courier/authmysqlrc 改名为 authmysqlrc.bak ,创建/etc/courier/authmysqlrc 输入下面的内容。

MYSQL_SERVER localhostMYSQL_USERNAME extmailMYSQL_PASSWORD extmailMYSQL_PORT 0MYSQL_OPT 0MYSQL_DATABASE extmailMYSQL_SELECT_CLAUSE SELECT username,password,"",uidnumber,gidnumber,CONCAT('/home/data/domains/',homedir),CONCAT('/home/data/domains/',maildir),quota,name FROM mailbox WHERE username = '$(local_part)@$(domain)'
修改authdaemond 的权限,让其它程序有权限访问他,重启authdaemond

chmod -R +x /var/run/courier/authdaemon

/etc/init.d/courier-authdaemon restart

B、创建测试用户的目录

mail:/etc/postfix# id postfix
uid=105(postfix) gid=106(postfix) groups=106(postfix)

mail:/etc/courier# mkdir -p /home/data/domains/extmail.org/testmail:/etc/courier# /usr/bin/maildirmake /home/data/domains/extmail.org/test/Maildir mail:/etc/courier# chown -R 105:106 /home/data/domains/
C、测试系统

打开一个窗口,输入 tail -f /var/log/mail.log

将测试的用户名和密码进行base64 编码

%perl -MMIME::Base64 -e 'print encode_base64("test\@extmail.org");' dGVzdEBleHRtYWlsLm9yZw==%perl -MMIME::Base64 -e 'print encode_base64("test");' dGVzdA==
测试smtpd 发邮件

mail:/etc/postfix# telnet localhost 25Trying 127.0.0.1...Connected to localhost.Escape character is '^]'.220 extmail.org ESMTP Mail Systemehlo test250-mail.extmail.org250-PIPELINING250-SIZE 14680064250-VRFY250-ETRN250-AUTH LOGIN PLAIN250-AUTH=LOGIN PLAIN250 8BITMIMEauth login334 VXNlcm5hbWU6dGVzdEBleHRtYWlsLm9yZw==334 UGFzc3dvcmQ6dGVzdA==235 Authentication successfulmail from:<test@test.com>250 Okrcpt to:<test@extmail.org>250 Okdata354 End data with .test.250 Ok: queued as C2FF131B85quit221 ByeConnection closed by foreign host.
mail.log 应该有如下记录

May 20 19:37:32 mail postfix/smtpd[1763]: connect from localhost[127.0.0.1]May 20 19:37:40 mail postfix/smtpd[1763]: disconnect from localhost[127.0.0.1]May 20 19:37:43 mail postfix/smtpd[1763]: connect from localhost[127.0.0.1]May 20 19:38:24 mail authdaemond.mysql: received auth request, service=smtp, authtype=loginMay 20 19:38:24 mail authdaemond.mysql: authmysql: trying this moduleMay 20 19:38:24 mail authdaemond.mysql: SQL query: SELECT username,password,"",uidnumber,gidnumber,CONCAT('/home/data/domains/',homedir),CONCAT('/home/data/domains/',maildir),quota,name FROM mailbox WHERE username = 'test@extmail.org'May 20 19:38:24 mail authdaemond.mysql: password matches successfullyMay 20 19:38:24 mail authdaemond.mysql: authmysql: sysusername=null, sysuserid=105, sysgroupid=106, homedir=/home/data/domains/extmail.org/test, address=test@extmail.org, fullname=Test user, maildir=/home/data/domains/extmail.org/test/Maildir/, quota=5242880, options=May 20 19:38:24 mail authdaemond.mysql: authmysql: clearpasswd=null>, passwd=uywiuN.XggXXcMay 20 19:38:24 mail authdaemond.mysql: authmysql: ACCEPT, username test@extmail.orgMay 20 19:38:47 mail postfix/smtpd[1763]: C2FF131B85: client=localhost[127.0.0.1], sasl_method=login, sasl_username=test@extmail.orgMay 20 19:38:52 mail postfix/cleanup[1770]: C2FF131B85: message-id=20060520113836.C2FF131B85@mail.extmail.orgMay 20 19:38:52 mail postfix/qmgr[1699]: C2FF131B85: from=test@test.com, size=328, nrcpt=1 (queue active)May 20 19:38:52 mail postfix/virtual[1772]: C2FF131B85: to=test@extmail.org, relay=virtual, delay=16, status=sent (delivered to maildir)May 20 19:38:52 mail postfix/qmgr[1699]: C2FF131B85: removedMay 20 19:38:55 mail postfix/smtpd[1763]: disconnect from localhost[127.0.0.1]
测试pop3 收邮件

mail:/etc/postfix# telnet localhost 110Trying 127.0.0.1...Connected to localhost.Escape character is '^]'.+OK Hello there.user test@extmail.org+OK Password required.pass test+OK logged in.list+OK POP3 clients that break here, they violate STD53.1 5392 423.retr 2+OK 423 octets follow.Return-Path: test@test.comX-Original-To: test@extmail.orgDelivered-To: test@extmail.orgReceived: from test (localhost [127.0.0.1]) by mail.extmail.org (Postfix) with ESMTP id C2FF131B85 for test@extmail.org; Sat, 20 May 2006 19:38:36 +0800 (CST)Message-Id: 20060520113836.C2FF131B85@mail.extmail.orgDate: Sat, 20 May 2006 19:38:36 +0800 (CST)From: test@test.comTo: undisclosed-recipients:;test.quit+OK Bye-bye.Connection closed by foreign host.
所产生的mail.log

如果你的pop3 信息没有我这里详细,请检查/etc/courier/pop3d 里面有没有打开 DEBUG_LOGIN=2

May 20 19:43:19 mail courierpop3login: Connection, ip=[::ffff:127.0.0.1]May 20 19:43:28 mail courierpop3login: LOGIN: DEBUG: ip=[::ffff:127.0.0.1], command=USERMay 20 19:43:32 mail courierpop3login: LOGIN: DEBUG: ip=[::ffff:127.0.0.1], command=PASSMay 20 19:43:32 mail courierpop3login: LOGIN: DEBUG: ip=[::ffff:127.0.0.1], username=test@extmail.orgMay 20 19:43:32 mail courierpop3login: LOGIN: DEBUG: ip=[::ffff:127.0.0.1], password=testMay 20 19:43:32 mail courierpop3login: authdaemon: starting client moduleMay 20 19:43:32 mail authdaemond.mysql: received auth request, service=pop3, authtype=loginMay 20 19:43:32 mail authdaemond.mysql: authmysql: trying this moduleMay 20 19:43:32 mail authdaemond.mysql: SQL query: SELECT username,password,"",uidnumber,gidnumber,CONCAT('/home/data/domains/',homedir),CONCAT('/home/data/domains/',maildir),quota,name FROM mailbox WHERE username = 'test@extmail.org'May 20 19:43:32 mail authdaemond.mysql: password matches successfullyMay 20 19:43:32 mail authdaemond.mysql: authmysql: sysusername=null>, sysuserid=105, sysgroupid=106, homedir=/home/data/domains/extmail.org/test, address=test@extmail.org, fullname=Test user, maildir=/home/data/domains/extmail.org/test/Maildir/, quota=5242880, options=null>May 20 19:43:32 mail authdaemond.mysql: authmysql: clearpasswd=null>, passwd=uywiuN.XggXXcMay 20 19:43:32 mail authdaemond.mysql: authmysql: ACCEPT, username test@extmail.orgMay 20 19:43:32 mail courierpop3login: authdaemon: ACCEPT, username test@extmail.orgMay 20 19:43:32 mail courierpop3login: LOGIN, user=test@extmail.org, ip=[::ffff:127.0.0.1]May 20 19:43:46 mail courierpop3login: LOGOUT, user=test@extmail.org, ip=[::ffff:127.0.0.1], top=0, retr=411, time=14
如果日志里出现:

authdaemond.mysql: supplied password 'extmail' does not match encrypted password'{crypt}uywiuN.XggXXc' 请用phpmyadmin检查extmail数据库中mailbox 表中用户密码前面的{crypt}是否已经删除。

如果出现 "Permission denied",请检查目录的权限,及extmail 数据库中mailbox 表中的uidnumber/gidnumber 是否和目录的权限一致。

至此,一个支持虚似域的邮件系统已配置完成,下面继续配置杀毒,反垃圾邮件。

 
     
 
 
后退<<上一页 继续>>下一页
[上一页][第1页][第2页][第3页][第4页][下一页]
 
内容导航  
第1页在DEBIAN 下安装POSTF.. 第2页在DEBIAN 下安装POSTF..
第3页在DEBIAN 下安装POSTF.. 第4页Debian
上一篇 : 怎样在 Debian GNU/Linu.. 下一篇风讯最新4.0SP1使用过程..
 
  您要为所发表的言论的后果负责,请各位遵纪守法并注意文明用语
标题:  

[ 关于本站 ] [ 广告服务 ] [ 商务合作 ] [ 联系我们 ] [ 合作伙伴 ] [ 法律顾问 ] [ 网站地图 ]
千橡公司 京ICP证041489号 Copyright (c) 1997-2007 All Right Reserved.