search
HomeBackend DevelopmentPHP Tutorial基于qmail的完整WEBMAIL解决方案安装详解_php基础

安装平台:Linux,Solaris
版本:qmail-1.03
安装的机器: mail.mydomain.com


软件包:
qmail-1.03 qmail基本系统
ucspi-tcp-0.88 tcpsever服务程序
daemontools-0.70 监视工具
checkpassword-0.81 pop3验证用户的程序
ezmlm-0.53 邮件转发
vpopmail-4.9.6-1 虚拟域用户pop3支持
qmailadmin-0.35 虚拟域web管理
autorespond-1.0.0 自动回复程序
sqwebmail-1.2.0 webmail
vqsignup-0.4 web方式用户注册
软件来源:
http://www.qmail.org
http://www.inter7.com/qmail
每个包安装前务必先仔细阅读INSTALL和FAQ,很多问题在FAQ都有解决方法。


安装步骤:

1. #mkdir /var/qmail

2. # groupadd nofiles
# useradd -g nofiles -d /var/qmail/alias alias
# useradd -g nofiles -d /var/qmail qmaild
# useradd -g nofiles -d /var/qmail qmaill
# useradd -g nofiles -d /var/qmail qmailp
# groupadd qmail
# useradd -g qmail -d /var/qmail qmailq
# useradd -g qmail -d /var/qmail qmailr
# useradd -g qmail -d /var/qmail qmails

3. #tar xzvf qmail-1.03.tar.gz
进入qmail目录后,仔细阅读一下README和INSTALL文件.然后开始编译qmail
#make setup check

4. #cd qmail-1.03
#./config

5. 建立系统别名
# (cd ~alias; touch .qmail-postmaster .qmail-mailer-daemon .qmail-root)
# chmod 644 ~alias/.qmail*

6. # cp /var/qmail/boot/home /var/qmail/rc
 # chmod 755 /var/qmail/rc

   编辑 /var/qmail/rc
   修改其中 ./Mailbox 成为 ./Maildir ,如下:

   # !/bin/sh
   # Using splogger to send the log through syslog.
   # Using qmail-local to deliver messages to ~/Maildir by default.
   exec env - PATH="/var/qmail/bin:$PATH"
   qmail-start ./Maildir splogger q

   其中 splogger qmail 指令是用来将纪录文件纪录于 / 中。
   建立样板
   $ /var/qmail/bin/maildirmake /etc/skel/Maildir
   $ echo ./Maildir/ > ~/.qmail
   注意 Maildir 必须为该使用者所有,可以 chown 变更,并以 chmod 700 Maildir 设定权限。


7. 安装 ucspi-tcp-0.88
   # tar zxvf ucspi-tcp-0.88.tar.gz
   # cd ucspi-tcp-0.88
   # make
   # make setup check
   执行档将被安装于 /usr/local/bin 中。


8. 安装 checkpassword
   # tar zxvf checkpassword-0.81.tar.gz
   # cd checkpassword-0.81
   # make
   # make setup check
   # chmod og-rx /bin/checkpassword
   执行档 checkpassword 将被安装于 /bin 中
如果不对/etc/passwd中的用户开放mail,不需要装checkpassword,只要装vpopmail

9. 安装 daemontools
   # tar zxvf daemontools-0.70.tar.gz
   # cd daemontools-0.70
   # make
   # make setup check
   执行档将安装于 /usr/local/bin 中

安装本工具后可以用
# mkdir /var/run/qmail
# supervise /var/run/qmail /var/qmail/rc
来启动qmail,可以用svc来关闭活重起qmail,用svstat监视qmail运行情况,(qmail FAQ)

10. 安装 vpopmail
# groupadd vchkpw
# useradd -g vchkpw vpopmail
# mkdir ~vpopmail/etc
# echo ":allow" > ~vpopmail/etc/tcp.smtp
# tar zvfz vpopmail-4.9.6-1.tar.gz
# cd vpopmail-4.9.6-1
# ./configure --enable-roaming-users=y --enable-default-domain=mydomain.com --enable-passwd=n
# make
# make install-strip

# crontab -e
40 * * * * /home/vpopmail/bin/clearopensmtp 2>&1 > /dev/null

# cd /home/vpopmail/bin
# ./vadddomain mydomain.com mydomain
append mydomain.com to /var/qmail/control/rcpthosts


11.停止sendmail 服务
   # killall -TERM sendmail (Linux)
   接着以 qmail 之 sendmail libraby 取代原有之 sendmail
   # mv /usr/lib/sendmail /usr/lib/sendmail.old
   # mv /usr/sbin/sendmail /usr/sbin/sendmail.old
   # ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
   # ln -s /var/qmail/sbin/sendmail /usr/sbin/sendmail
移除 sendmail 启动程序,以 Linux 为例:
   移除 inetd.conf 中的 sendmail 之设定,以及 /etc/rc.d/init.d 下的 sendmail 启动档。(Linux)


12.启动qmail SMTP , POP3 daemon 系统服务

   建立 SMTP 转信规则
   建立 /etc/tcp.smtp 内容为
   :allow
   此为接受任何Client端所发出之转送信件
   若要拒绝某些IP所发出之Relay则改为 /etc/tcp.smtp如下
   1.2.3.4:allow,RELAYCLIENT=""
   127.:allow, RELAYCLIENT=""
   如此,除1.2.3.4及127.*之外的所有地址,都将被拒绝转送信件。
   
   接下来,转换 tcp.smtp 成为 cdb 格式。
   # /usr/local/bin/tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp
   注意:若对 tcp.smtp 有任何变更,都必须经过 tcprules 转换成为 cdb 才会生效。
   另外,tcp.smtp 若为空白,则表示拒绝所有的转送,因为预设的规则为 deny。
   至此,转送规则已建立,稍后将依此规则启动 qmail-smtpd。

   设定 SMTP 及 POP3 daemon 之启动
   请移除 inetd.conf 中有关 smtp 及 pop3 的设定 (加上 # 号)
   编辑 /etc/services,改为以下设定:

   smtp 25/tcp mail
   # pop-3 110/tcp #pop version 3
   # pop-3 110/udp
   pop3 110/tcp
   pop3 110/udp

   启动 SMTP:
   /usr/local/bin/tcpserver -v -x /etc/tcp.smtp.cdb
   -u UID -g GID 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
   | /var/qmail/bin/splogger smtpd 3 &

   其中UID和GID为前述新增 qmail 系统账号之 qmaild 之 User ID,以及 nofiles 之 group ID。
   /var/qmail/bin/splogger那一行会将log档写在 /var/log/maillog。

   启动 POP3:
   编辑启动档加入以下设定:
   tcpserver -H -R 0 pop3
/var/qmail/bin/qmail-popup mail.mydomain.com
/home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir &


在/etc/rc.d/init.d下建立文件qmail,内容如下:
-------------------------------------------
#! /bin/sh

case "$1" in
start)
echo -n "start qmail:"
/var/qmail/rc &
echo "."

echo -n "start smtp service:"
    /usr/local/bin/tcpserver -v -x /etc/tcp.smtp.cdb
    -u UID -g GID 0 smtp /var/qmail/bin/qmail-smtpd 2>&1
    | /var/qmail/bin/splogger smtpd 3 &
echo "."

echo -n "start pop3 service:"
   tcpserver -H -R 0 pop3
/var/qmail/bin/qmail-popup mail.mydomain.com
/home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir &
echo "."

stop)
echo -n "stop qmail:"
echo "."

*)
exit 1

esac

exit 0
-----------------------------------------------------
# cd ../rc3.d
# ln -s ../init.d/qmail S98qmail


qmailadmin WEB方式管理qmail

1 ezmlm
$ make
$ make man
# make setup

2 autorespond
gcc -Wall -o autorespond autorespond.c
cp autorespond /usr/local/bin/autorespond

3 qmailAdmin

3.1. 在你开始以前还有几件事需要考虑.
a. 你是否有vpopmail 用户而且已经安装了vchkpw
b. 你的 cgi bin 目录的位置
c. 你的 ezmlm 目录的位置
d. 你的 autorespond 目录的位置
如果这些部分你有忽略,那先暂停继续,先把这些搞定吧!!


3.2 install

# ./configure
# make
# make install-strip

浏览器中打开路径http://mail.mydomain.com/cgi-bin/qmailadmin
用户postmaster;域mydomain.com;口令:mydomain


WebMail -- SqWebmail
# tar xvfz sqwebmail-1.2.0.tar.gz
# cd sqwebmail-1.2.0
# ./configure --without-authpam --without-authuserdb --enable-webpass=no --without-authpwd --without-authshadow
# make configure-check
# make (当我make的时候报错找不到db.h,cp /usr/include/db1/db.h /usr/include/db.h)
# make check
# make install-strip
# make install-configure
浏览器中打开路径http://mail.mydomain.com/cgi-bin/sqwebmail

vqsignup
# tar xvfz vqsignup-0.4.tar.gz
# cd vqsignup-4.0

按照INSTALL安装

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
11 Best PHP URL Shortener Scripts (Free and Premium)11 Best PHP URL Shortener Scripts (Free and Premium)Mar 03, 2025 am 10:49 AM

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Introduction to the Instagram APIIntroduction to the Instagram APIMar 02, 2025 am 09:32 AM

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

Build a React App With a Laravel Back End: Part 2, ReactBuild a React App With a Laravel Back End: Part 2, ReactMar 04, 2025 am 09:33 AM

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Announcement of 2025 PHP Situation SurveyAnnouncement of 2025 PHP Situation SurveyMar 03, 2025 pm 04:20 PM

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment