当前位置:文档之家› linux环境下postfix+dovecot+webmail安装配置详解

linux环境下postfix+dovecot+webmail安装配置详解

构建postfix邮件服务器(一)1、编译安装Postfix[root@mail ~]# groupadd -g 1200 postdrop[root@mail ~]# groupadd -g 1000 postfix[root@mail ~]# useradd -M -s /sbin/nologin -u 1000 -g postfix -G postdrop postfix[root@mail ~]# tar zxf postfix-2.4.6.tar.gz[root@mail ~]# gunzip postfix-2.4.6-vda-ng.patch.gz[root@mail ~]# cd postfix-2.4.6[root@mail postfix-2.4.6]# patch -p1 < ../postfix-2.4.6-vda-ng.patchpatching file README_FILES/VDA_READMEpatching file src/global/mail_params.hpatching file src/util/file_limit.cpatching file src/virtual/mailbox.cpatching file src/virtual/maildir.cpatching file src/virtual/virtual.cpatching file src/virtual/virtual.h[root@mail postfix-2.4.6]#预配置编译参数[root@mail postfix-2.4.6]# make makefiles \'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql \-DUSE_SASL_AUTH \-DUSE_CYRUS_SASL -I/usr/include/sasl' \'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm \-L/usr/lib/sasl2 -lsasl2 ' && make && make install //编译并进行安装Postfix的配置文件(Postfix系统最主要的配置文件包括:/etc/postfix/main.cf 和/etc/postfix/master.cf.前者是postfix服务的配置文件,后者是master程序的配置文件)[root@mail postfix-2.4.6]# postconf –n //-n 将只列出不同于默认值的配置参数command_directory = /usr/sbinconfig_directory = /etc/postfixdaemon_directory = /usr/libexec/postfixdebug_peer_level = 2html_directory = nomail_owner = postfixmailq_path = /usr/bin/mailqmanpage_directory = /usr/local/mannewaliases_path = /usr/bin/newaliasesqueue_directory = /var/spool/postfixreadme_directory = nosample_directory = /etc/postfixsendmail_path = /usr/sbin/sendmailsetgid_group = postdropunknown_local_recipient_reject_code = 550[root@mail postfix-2.4.6]#[root@mail postfix-2.4.6]# cd /etc/postfix/[root@mail postfix]# postconf -n > main2.cf[root@mail postfix]# mv main.cf main.cf.bak[root@mail postfix]# mv main2.cf main.cfPostfix的启动控制[root@mail postfix]# postfix startpostfix/postfix-script: starting the Postfix mail system[root@mail postfix]# netstat -anpt | grep :25tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 1995/master[root@mail postfix]# postfix check //若配置无误,不会反馈任何信息[root@mail postfix]# postfix reload //重新载入配置信息,而不需要重启Postfix服务postfix/postfix-script: refreshing the Postfix mail system[root@mail postfix]# postfix stoppostfix/postfix-script: stopping the Postfix mail system[root@mail postfix]#配置基于Postfix构建简单电子邮件系统:1、编辑main.cf文件,调整运行Postfix的基本参数[root@mail postfix]#vi main.cfinet_interfaces=192.168.1.199, 127.0.0.1 //设置postfix服务监听的IP地址,缺省为allmyhostname= //设置postfix服务器使用的主机名mydomain= //设置postfix服务器使用的邮件域myorigin=$mydomain //设置外发邮件时发件人地址中的邮件域名mydestination=$mydomain,$myhostname //设置可接收的邮件地址中的域名home_mailbox=Maildir/ //设置邮件存储位置和格式2、添加邮件用户的帐号[root@mail postfix]# groupadd mailusers[root@mail postfix]# useradd -g mailusers -s /sbin/nologin xiaowu[root@mail postfix]# useradd -g mailusers -s /sbin/nologin juncai[root@mail postfix]# passwd xiaowuChanging password for user xiaowu.New UNIX password:BAD PASSWORD: it is based on a dictionary wordRetype new UNIX password:passwd: all authentication tokens updated successfully.[root@mail postfix]# passwd juncaiChanging password for user juncai.New UNIX password:BAD PASSWORD: it is based on a dictionary wordRetype new UNIX password:passwd: all authentication tokens updated successfully.[root@mail postfix]##echo 12345 | passwd --stdin xiaowu //或这样赋予密码Changing password for user xiaowu.passwd: all authentication tokens updated successfully.3、SMTP发送邮件测试[root@mail postfix]# telnet localhost 25Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.220 ESMTP Postfixehlo 250 250-PIPELINING250-SIZE 10240000250-VRFY250-ETRN250-ENHANCEDSTATUSCODES250-8BITMIME250 DSNmail from:xiaowu@250 2.1.0 Okrcpt to:juncai@250 2.1.5 Okdata354 End data with <CR><LF>.<CR><LF>subject: A TEST MAILHELLO!This is a test mail !!!.250 2.0.0 Ok: queued as 229784E100quit221 2.0.0 ByeConnection closed by foreign host.#grep 229784E100 /var/log/messages //查找发信状态[root@mail postfix]# cat ~juncai/Maildir/new/Return-Path: <xiaowu@>X-Original-To: juncai@Delivered-To: juncai@Received: from localhost (localhost.localdomain [127.0.0.1])by (Postfix) with SMTP id 229784E100for <juncai@>; Thu, 17 Mar 2011 03:02:45 +0800 (CST)subject: A TEST MAILMessage-Id: <20110316190254.229784E100@>Date: Thu, 17 Mar 2011 03:02:45 +0800 (CST)From: xiaowu@To: undisclosed-recipients:;HELLO!This is a test mail !!![root@mail postfix]#构建Dovecot服务器1、编译安装Dovecot软件包[root@mail ~]#useradd –M –s /sbin/nologin dovecot[root@mail ~]#tar zxvf dovecot-1.1.4.tar.gz[root@mail ~]#cd dovecot-1.1.4[root@mail dovecot-1.1.4]# ./configure --sysconfdir=/etc --with-mysql && make && make install2、配置Dovecot的运行参数(1)建立dovecot.conf配置文件并进行简单设置[root@mail dovecot-1.1.4]# cp /etc/dovecot-example.conf /etc/dovecot.conf[root@mail dovecot-1.1.4]#vi /etc/dovecot.confssl_disable = yesprotocols = imap pop3disable_plaintext_auth = nomail_location = maildir:~/Maildir(2)创建PAM认证文件[root@mail dovecot-1.1.4]# vi /etc/pam.d/dovecotauth required pam_nologin.soauth include system-authaccount include system-authsession include system-auth3、启动Dovecot服务[root@mail ~]# /usr/local/sbin/dovecot -c /etc/dovecot.conf[root@mail ~]# netstat -anpt | grep dovecottcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 3713/dovecottcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 3713/dovecot[root@mail ~]#4、POP3接收邮件测试[root@mail ~]# telnet localhost 110Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.+OK Dovecot ready.user juncai+OKpass juncai+OK Logged in.list+OK 1 messages:1 511.retr 1+OK 511 octetsReturn-Path: <xiaowu@>X-Original-To: juncai@Delivered-To: juncai@Received: from localhost (localhost.localdomain [127.0.0.1])by (Postfix) with SMTP id 229784E100for <juncai@>; Thu, 17 Mar 2011 03:02:45 +0800 (CST) subject: A TEST MAILMessage-Id: <20110316190254.229784E100@>Date: Thu, 17 Mar 2011 03:02:45 +0800 (CST)From: xiaowu@To: undisclosed-recipients:;HELLO!This is a test mail !!!.quit+OK Logging out.Connection closed by foreign host.[root@mail ~]#WEBMAIL邮件界面SquirrelMail的工作流程1、依次安装squirrelmail程序包、中文语言包[root@mail ~]# tar jxvf squirrelmail-1.4.13.tar.bz2 -C /usr/local/apache2/htdocs /webmail[root@mail ~]# cd /usr/local/apache2/htdocs/webmail/[root@mail webmail]# tar jxvf ~/zh_CN-1.4.13-20071220.tar.bz22、创建及调整数据目录、附件目录[root@mail webmail]# mkdir -p attach data[root@mail webmail]# chown -R daemon:daemon attach/ data/ [root@mail webmail]# chmod 730 attach/3、建立config.php配置文件[root@mail webmail]# cp config/config_default.php config/config.php [root@mail webmail]# vi config/config.php$squirrelmail_default_language = 'zh_CN';'en_US' $default_charset = 'zh_CN.UTF-8'; 'iso-8859-1' $domain = '';$smtpServerAddress = 'localhost';$smtpPort = 25;$imapPort = 143;$imap_server_type = 'dovecot';$data_dir = '/usr/local/apache2/htdocs/webmail/data/'; $attachment_dir = '/usr/local/apache2/htdocs/webmail/attach/';4、重新启动httpd服务,并在浏览器中登录squirrelmail系统[root@mail webmail]# ../../bin/apachectl restart在该界面中可以完成发信、收信等电子邮件服务的基本操作。

相关主题