----------------------------------
一、前言
二、配置postfix
三、安装squirrelmail
四、测试squirrelmail
五、squirrelmail常见错误及排除
---------------------------------
一、前言
postfix是Wietse Venema在IBM的GPL协议之下开发的MTA(邮件传输代理)软件。postfix是Wietse Venema想要为使用最广泛的sendmail提供替代品的一个尝试。在Internet世界中,大部分的电子邮件都是通过sendmail来投递的,大约有100万用户使用sendmail,每天投递上亿封邮件。这真是一个让人吃惊的数字。Postfix试图更快、更容易管理、更安全,同时还与sendmail保持足够的兼容性。
SquirrelMail是一套基于标准的,采用PHP4开发Webmail邮件系统。它内置纯PHP支持的IMAP和SMTP协议,所有页面都遵循HTML4.0标准(没有使用JavaScript支持),以便最大限度兼容更多浏览器上。它对系统要求非常低,并且安装和配置非常容易。SquirrelMail具备一个客户端邮件程序所应拥有的一切功能,包括支持增强型的MIME、地址薄、文件夹操作等等功能。
二、配置postfix
# yum install postfix # vim /etc/postfix/main.cf
75 myhostname = mail.abc.com
定义本地主机名
83 mydomain = abc.com
本地域名
99 myorigin = $mydomain
引用本地域名
113 inet_interfaces = all
114 #inet_interfaces = $myhostname
115 #inet_interfaces = $myhostname, localhost
116 #inet_interfaces = localhost
开启所有端口
164 #mydestination = $myhostname, localhost.$mydomain, localhost,
165 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomai
264 mynetworks = 127.0.0.0/8
267 broken_sasl_auth_clients = yes
268 smtpd_sasl_auth_enable = yes
269 smtpd_sasl_security_options = noanonymous
270 #smtpd_sasl_application_name = smtpd
271 smtpd_client_restrictions = permit_sasl_authenticated,reject
272 #smtpd_client_restrictions = permit_sasl_authenticated
273 smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,
reject_unauth_destination
添加身份验证,sasl的配置
# service postfix start # service saslauthd start
三、安装squirrelmail
# yum install httpd php # tar -zxvf squirrelmail-webmail-1.4.22.tar.gz -C /var/www/html/ # cd /var/www/html/ # mv squirrelmail-webmail-1.4.22/ webmail # cd webmail # ./configure
仅需更改以下三点即可。
Server Settings abc.com
Default Language zh_CN
Default Charset gb2312
根据doc/INSTALL文档修改配置
修改配置
# cd /var/www/html/webmail # chown -R apache:apache data/ # mkdir /var/local/squirrelmail # cd /var/local/squirrelmail/ # mkdir attach # chgrp -R apache attach/ # chmod 730 attach/ # vim /var/www/html/webmail/config/config.php 64 $data_dir = '/var/www/html/webmail/data/'; 65 $p_w_upload_dir = '/var/local/squirrelmail/attach/'; # service httpd start
四、测试squirrelmail
1.本地测试
# echo -n 'user1@abc.com' |openssl base64 dXNlcjFAYWJjLmNvbQ== # echo -n '123' |openssl base64 MTIz # telnet 127.0.0.1 25 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. 220 mail.abc.com ESMTP Postfix EHLO 127.0.0.1 250-mail.abc.com 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN auth login dXNlcjFAYWJjLmNvbQ== 334 UGFzc3dvcmQ6 MTIz 235 2.7.0 Authentication successful mail from:user1@abc.com 250 2.1.0 Ok rcpt to:root@abc.com 250 2.1.5 Ok data 354 End data with <CR><LF>.<CR><LF> subject:1 1111111111111111 . 250 2.0.0 Ok: queued as 15812A2E9E quit 221 2.0.0 Bye Connection closed by foreign host. You have new mail in /var/spool/mail/root # mail Heirloom Mail version 12.4 7/29/08. Type ? for help. "/var/spool/mail/root": 1 messages 1 new > N 1 user1@abc.com Wed Mar 5 03:33 15/465 "1" & 1 Message 1: From user1@abc.com Wed Mar 5 03:33:06 2014 Return-Path: <user1@abc.com> X-Original-To: root@abc.com Delivered-To: root@abc.com subject:1 Date: Wed, 5 Mar 2014 03:32:31 -0800 (PST) From: user1@abc.com To: undisclosed-recipients:; Status: R 1111111111111111 & q
2.浏览器访问http://192.168.30.10/webmail
squirrelmail登陆界面。(建议关闭防火墙和SElinux)
squirrelmail主界面,可以查看邮件。
五、squirrelmail常见错误及排除
1.登陆后出现错误,提示权限不够。
建议关闭防火墙和SElinux
2.登陆后出现错误,提示拒绝连接。
安装dovecot并开启IMAP服务。
# yum install dovecot # service dovecot start
3.squirrelmail找不到用户邮箱位置
# vim /etc/dovecot/conf.d/10-mail.conf 25 mail_location = mbox:~/mail:INBOX=/var/mail/%u # service dovecot restart
4.INBOX错误,将用户添加到mail组即可。
# usermod -a -G mail user1
5.Error opening ../data/default_pref
# chown -R apache:apache data/
6.登陆后无法发送邮件。
# vim /etc/postfix/main.cf 271 #smtpd_client_restrictions = permit_sasl_authenticated,reject
PS:su user2与su - user2的区别
# su user2 $ mail /var/spool/mail/root: Permission denied # su - user2 Password: $ mail Heirloom Mail version 12.4 7/29/08. Type ? for help. "/var/spool/mail/user2": 1 messages > 1 user1@abc.com Wed Mar 5 04:43 30/874 "1"