|
|
发表于 2007-3-7 12:58:21
|
显示全部楼层
Debian+postfix+openwebmail架设(尼奥科技-邱立波)
Debian+postfix+openwebmail架设(邱立波)
这是笔者自己架设过程中记下并整理的笔记:
可用openwebmail在web中收发信件,也可以
用foxmail,outlook等客户端通过pop3,smtp收发信件.
Postfix+sasl2+openwebmail install on Debian Sarge
Postfix的安装必须严格按以下顺序安装,否则会出现saslauthd不能正常验证
先安装postfix ¬¬¬-¬¬¬¬¬--接着安装sasl------最后装 openwebmail
安装postfix
1、apt-get install postfix postfix-tls postfix-doc(可选) postfix-mysql(可选)
Internet Site--->postmaster--->mail.35post.com----->mail.35post.com, localhost.35post.com, , localhost, 35post.com
2、mkdir /etc/postfix/sasl
vi /etc/postfix/sasl/smtpd.conf
pwcheck_method: saslauthd
mech_list: plain login
3、vi /etc/postfix/main.cf
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
append_dot_mydomain = no
myhostname = 35post.com
mydomain = 35post.com
#alias_maps = hash:/etc/aliases, ldap:/etc/postfix/ldap-aliases.cf
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = 35post.com
mydestination = $myhostname
relayhost =
mynetworks = 127.0.0.0/8, 192.168.1.0/24, 59.60.10.112/29
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
#home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated, reject_unauth_destination
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous
注: openwebmail默认邮件格式为 mail, 切记postfix 不用进行home_mailbox设置即与openwebmail相同
所以注销这行#home_mailbox = Maildir/
4、vi /etc/postfix/master.cf
smtp inet n - n - - smtpd
smtp unix - - n - - smtp
5、postalias /etc/aliases
/etc/init.d/postfix restart
检查 netstat -nap |grep 25
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 1401/master
ps aux |grep master
root 1401 0.0 0.5 3656 1320 ? Ss 18:49 0:00 /usr/lib/postfix/master
安装cyrus-sasl2
1、apt-get install sasl2-bin libsasl2 libsasl2-modules (libsasl2-modules-sql可选)
2、vi /etc/default/saslauthd
START=yes
MECHANISMS="shadow"
3、 chown -R root:sasl /var/run/saslauthd chmod -R 710 /var/run/saslauthd addgroup postfix sasl
4、 /etc/init.d/saslauthd start /etc/init.d/postfix restart
5、检查testsaslauthd -u pqiu -p qwer1234
0: OK "Success."
mail:~# telnet mail.35post.com 25
Trying 59.60.10.115...
Connected to mail.35post.com.
Escape character is '^]'.
220 35post.com ESMTP Postfix (Debian/GNU)
ehlo 35post.com
250-35post.com
250-PIPELINING
250-SIZE 100240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250 8BITMIME
出现上面红色的两行为成功
6、进一步测试:
apt-get install metamail
printf 'pqiu\0pqiu\0qwer1234' | mimencode
cHFpdQBwcWl1AHF3ZXIxMjM0
addgroup postfix sasl
/etc/init.d/saslauthd restart
/etc/init.d/postfix restart
mail:~# telnet mail.35post.com 25
Trying 59.60.10.115...
Connected to mail.35post.com.
Escape character is '^]'.
220 35post.com ESMTP Postfix (Debian/GNU)
ehlo 35post.com
250-35post.com
250-PIPELINING
250-SIZE 100240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250 8BITMIME
AUTH PLAIN cHFpdQBwcWl1AHF3ZXIxMjM0
235 Authentication successful
测试成功,如果测试失败,原因是没有把postfix 加入sasl组
加入后重启saslauthd和postfix,现测试成功。
安装openwebmail
1. vi /etc/apt/sources.list 加入下面一行
deb ftp://debian.tnc.edu.tw/pub1 b2d/
apt-get update
apt-get install openwebmail
當出現 Send the site report?(Y/n) 時, 回答 n
Please *restart* your Apache2 ! 時, 回答 y
2. vi /usr/lib/cgi-bin/openwebmail/etc/openwebmail.conf
#domainnames auto
domainnames 35post.com
3. http://59.60.10.115/cgi-bin/openwebmail/openwebmail.pl
或 http://mail.35post.com/cgi-bin/openwebmail/openwebmail.pl
4. 转址 如转为 mail.35post.com
首先修改 /etc/apache2/apache2.conf
将 DirectoryIndex index.html index.cgi index.pl index.php index.xhtml 改为
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml (将index.php挪到第一个)
接着comment out 这行(去掉#号)
#AddType application/x-httpd-php .php
最后保存,并重启apache2: /etc/init.d/apache2 restart
在/var/www/apache2-default里建一文件index.php其内容为
<?php
header( 'Location: http://59.60.10.115/cgi-bin/openwebmail/openwebmail.pl' );
?>
或者
<?php
header( 'Location: http://mail.35post.com/cgi-bin/openwebmail/openwebmail.pl' );
?>
到这里转址完成,可用 mail.35post.com直接访问
5. 登录画面的修改
用公司相应的gif图片(最好大小一样)替换/var/www/openwebmail_data/images/openwebmail.gif
修改图片链接到公司网站
编辑 /usr/lib/cgi-bin/openwebmail/etc/openwebmail.conf 加入以下一行
logo_link http://www.neurostechnology.com
附注说明: postfix smtp采用saslauthd验证
1. 安装postfix时必须把postfix-tls安装上,这个包是支持SASL,即使不用TLS,也应装上
apt-get install postfix postfix-tls
2. 让postfix不要使chroot方式启动
vi /etc/postfix/master.conf
将smtp inet n - - - - smtpd 改为
smtp inet n - n - - smtpd
将smtp unix - - - - - smtp 改为
smtp unix - - n - - smtp
3. 修改 /etc/default/saslauthd 让saslauthd使用 /etc/shadow验证
START=yes
MECHANISMS="shadow"
用ps aux |grep saslauthd查得
root 25602 0.0 0.1 6916 1624 ? S Feb09 0:00 /usr/sbin/saslauthd -a shadow
4. 创建 /etc/postfix/sasl/smtpd.conf 指定验证方法为saslauthd,验证机制为 palin login
pwcheck_method: saslauthd
mech_list: plain login
5. 安装cyrus-sasl2包 apt-get install sasl2-bin libsasl2 libsasl2-modules
6. 将postfix加入sasl组,修改/var/run/saslauthd权限使行posftfix可访问
chown -R root:sasl /var/run/saslauthd chmod -R 710 /var/run/saslauthd addgroup postfix sasl
7. 配置poftfix,让postfix支持saslauthd验证,在/etc/postfix/main.cf中加入以下行
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated, reject_unauth_destination
mtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous
附注:安装过程中使用的镜像源
cat /etc/apt/sources.list
deb ftp://debian.cn99.com/debian/ stable main
deb-src ftp://debian.cn99.com/debian/ stable main
deb ftp://218.22.45.5/debian/ sarge non-free main contrib
deb http://210.188.213.230/archives/linux/debian/debian-non-US/ stable/non-US main contrib
deb ftp://debian.tnc.edu.tw/pub1 b2d/ |
|