Home Backend Development PHP Tutorial 基于qmail的完整WEBMAIL解决方案安装详解_php基础

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

May 17, 2016 am 09:49 AM

安装平台: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 of this Website
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

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1269
29
C# Tutorial
1248
24
PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Apr 17, 2025 am 12:06 AM

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values ​​to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

How does PHP type hinting work, including scalar types, return types, union types, and nullable types? How does PHP type hinting work, including scalar types, return types, union types, and nullable types? Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

See all articles