---参考文章:http://blog.csdn.net/winscar/article/details/6483322
--->postfix+squirrelmail邮件系统
------------------------->debian6 系统
-----------------------------> vmware 7 虚拟机
---------------------------------------------> windows 7系统
############
1.安装系统
debian系统是pxe网络安装的----关于安装debian系统之前有一片文章写下来了
---
安装完成之后需要为后续安装的虚拟系统做准备。最主要的是虚拟连接的配置,这里就着重介绍下虚拟连接的配置过程。
在默认情况下,在虚拟机安装成功之后,系统会自动添加两个虚拟连接:VMNET1 , VMNET8 。我们对它们的 IP 地址和网关暂时先不进行配置。先打开虚拟机,在菜单 Edit 下点开 Virtual network editor 。在 summary 标签下我们可以看到虚拟机建立的虚拟连接,它们有各自的作用。这里以 NAT 为例介绍配置过程。
点开NAT 标签,在 VMnet host 下拉框内选择 VMnet8 (选择其他也可以,只是在后期的配置过程中有所不同)。点击应用了之后,可以看到普通情况下不可修改的 Gateway ip address ,记录下来。之后一路确定退出。然后回头在系统网络连接里修改 VMnet8 的 IP 地址,子网掩码以及网关。将网关改成刚刚记录的那个网关,子网掩码自动生成, IP 地址改成与该网关同网段的 IP 即可(不得与网关重 IP )。
到此这个步骤结束。
-------------
2.安装邮件系统软件包
root@debian:# apt-get install postfix libsasl2-2 sasl2-bin libsasl2-modules dovecot-imapd dovecot-pop3d dovecot-common
接下来,系统会检查网络进行连接,下载并安装软件包等。安装过程中会询问关于邮件服务器的设置,此处由于要提供对外网的邮件接受发送服务,所以选择internet site 。这中间任何一个软件包的安装都不能出错,如果出错请根据提示进行检查安装,否则会影响后期配置。
在安装完成之后,我们进入配置阶段
3 配置邮件服务器
首先,停掉这三项服务:
sudo /etc/init.d/saslauthd stop
sudo /etc/init.d/postfix stop
sudo /etc/init.d/dovecot stop
接下来,修改postfix 的配置文件 /etc/postfix/main.cf
由于采用了sasl 做认证,同时用 dovecot 作为 pop3 、 imap 和 smtp 的服务,所以需要修改 postfix 的配置文件以适应需求。
在/etc/postfix/main.cf 文件中增加以下信息以支持 sasl 认证和 dovecot 服务。
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = yourdomain.com
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_sasl_security_options = noanonymous
另外main.cf 中的以下两个参数
myhostname = yourhostname
mydestination = yourdomain.com, localhost.localdomain, localhost
分别代表了你的服务器信息,myhostname 是你当前主机名, mydestination 其中的 yourdomain.com 则是邮件服务器名。
修改完毕后保存该文件。
接下来,修改/etc/dovecot/dovecot.conf 文件
修改参数protocols 为
protocols = pop3 imap
设置参数disable_plaintext_auth 为
disable_plaintext_auth = no
找到auth default ,将 auth default 改名为 auth default2 。
然后在这行前面增加如下信息
auth default {
mechanisms = plain login
passdb pam {
}
userdb passwd {
}
socket listen {
client {
path = /var/spool/postfix/private/auth
mode = 0660
user = postfix
group = postfix
}
}
}
注意:这里的每个‘{ ’前都有个空格。
然后保存该文件。
接下来,修改sasl 配置文件。
debian默认的安装配置中 sasl 并不会自动启动,需要修改 /etc/default/saslauthd 文件。
将其中的START=no 修改为 START=yes 。
修改
OPTIONS="-c -m /var/run/saslauthd"
为
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd"
然后保存该文件。
在启用sasl 的情况下 postfix 运行需要 sasldb2 文件在 postfix 的 chroot 环境中。
同时为了保证saslauthd 能和 postfix 通讯,需要作如下的修改。
删除位于/va/run 目录下的 saslauthd 目录,然后创建一个指向 /var/spool/postfix/var/run/saslauthd 的符号连接。
sudo rm -r /var/run/saslauthd/
sudo mkdir -p /var/spool/postfix/var/run/saslauthd
sudo ln -s /var/spool/postfix/var/run/saslauthd /var/run
sudo chgrp sasl /var/spool/postfix/var/run/saslauthd
sudo adduser postfix sasl
另外postfix 在运行的时候需要将 /etc/sasldb2 文件拷贝到 chroot 环境中。
修改/etc/init.d/postfix 文件,修改其中的 FILES 变量,在其中增加 etc/sasldb2
完成以上工作后启动三个服务。
sudo /etc/init.d/saslauthd start
sudo /etc/init.d/postfix start
sudo /etc/init.d/dovecot start
然后新增用户
adduser username
至此,邮件服务器的配置成功。
4.配置squirrelMail
在终端输入命令以下载安装squirrelMail 。
命令如下:
#apt-get install squirrelmail
之后会提示安装,安装成功后我们进入配置阶段。
打开squirrelmail 的配置工具,在终端输入:
1.#/usr/share/squirrelmail/config/conf.pl
2.Command>>d
3.设置IMAP 服务器类型名为: dovecot
4.Command>>2
5.将domain 改成 yourdomainname , sendmail or SMTP 改成 SMTP
6.Command>>s
Squirrelmail的基本配置完成,现在可以通过浏览器查看网页邮箱了。在这之前,还需要配置下 apache2 。配置如下:
#cd /etc/apache2
#vim apache2.conf
然后在打开的文件内部添加下面这一行
Include /etc/squirrelmail/apache.conf
#/etc/init.d/apache2 restart
至此,配置结束
5.测试
利用命令
#adduser username
在服务器内部添加几个用户,利用这几个用户来测试邮件服务器是否配置成功。
打开浏览器,输入网址http://yourdomainname/squirrelmail 进行测试。
6.附加注意
配置完上述的服务器只是个开始,后面的所有调试部分是最需要配置者自行进行研究的部分。在上述配置完成后,后续的调试极少有直接成功的,在不成功的情况下,希望大家自行利用各种工具和手段进行故障排除和问题解决。下面给出一些建议:
1.查询系统邮件日志文件:/var/log/mail.log
2.查询各种配置文件:/etc/postfix/main.cf /etc/dovecot/dovecot.conf /etc/apache/apache.conf ……
3.谷歌,雅虎,百度……
在配置 dovecot.conf重启服务后一直报错,用测试账号登陆http://域名/squirrelmail --- 报错登陆不上,之后按一下内容修改后可以访问了,但是重启dovecot服务还是会有错误提示---
##########
在 dovecot.conf 添加了如下一句:
mail_location = mbox:~/mail:INBOX=/var/mail/%u
在 main.cf 注释掉了如下这句:
mailbox_command = procmail -a "$EXTENSION"
部分配置文件如下所示》
root@debian:~# vi /etc/postfix/main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
/mailbox
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = debian.guo
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_sasl_security_options = noanonymous
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = debian.guo
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = debian.guo, localhost.guo, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128mailbox_command = procm
ail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
root@debian:~# vi /etc/postfix/main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
/mailbox
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = debian.guo
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_sasl_security_options = noanonymous
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = debian.guo
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = debian.guo, localhost.guo, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
#mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
"/etc/postfix/main.cf" 51L, 1551C written
root@debian:~# /etc/init.d/saslauthd start
Starting SASL Authentication Daemon: saslauthd (already running).
root@debian:~# /etc/init.d/postfix start
Starting Postfix Mail Transport Agent: postfix.
root@debian:~# /etc/init.d/dovecot start
doveconf: Warning: NOTE: You can get a new clean config file with: doveconf -n > dovecot-new.conf
doveconf: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:4: add auth_ prefix to all settings inside auth {} and remove the auth {} section completely
doveconf: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:8: passdb pam {} has been replaced by passdb { driver=pam }
doveconf: Warning: Obsolete setting in /etc/dovecot/dovecot.conf:12: userdb passwd {} has been replaced by userdb { driver=passwd }
Starting IMAP/POP3 mail server: dovecot.
root@debian:~#
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com