[Transfer from Chinese FreeBSD User Group] QMail Server HOWTO

xiaoxiao2021-03-06  48

Qmail Server HOWTO

HD This article I should write very early, because the QMail's stuff has been very much, but it has been lazy, the biggest problem that caused all for FreeBSD every time. The QMAIL system is re-reading the article. Today, I finally decided to write while I was. First, install qmail installation qmail is simple, use Qmail in Ports to install it:

CD / USR / PORTS / MAIL / QMAIL

Make -dwith_big_todo_patch install

Make disable-sendmail

Make enable-qmail

Make clean

The third step and fourth step here is to change the default MAIL of Sendmail into qmail. It should be noted that this setting must be added in /etc/rc.conf:

Sendmail_enable = "none"

Sendmail_submit_enable = "no"

Sendmail_outbound_enable = "no"

Sendmail_msp_queue_enable = "no"

These will completely do anything from Sendmail when the system is started.

In general, we will use qmail's maildir way to launch QMail, so we need to activate the Maildir boot script, but we have to prepare for the SVScan behind, so the following script:

ENV ENV - PATH = "/ VAR / Qmail / bin: / usr / local / bin" /

qmail-start ./maildir/

Put in the RC file in / var / qmail. And use the CHMOD X / VAR / QMAIL / RC command to add execution permissions. Note: If you are installed when you install QMail, if you find it can't find your domain name resolution, you will not install all, here you need to manually configure it:

CD / var / qmail / configure

./config-fast $ hostname

Please use the host name of your machine instead of $ hostname. After this operation, QMAIL's default configuration file is automatically generated.

Second, install and set mysql

Installing MySQL is required for time instead of skill:

CD / USR / PORTS / DATABASES / MYSQL40-Server

Make -dwith_charset = GBK Install

Make clean

We have to prepare the mysql library and users in advance in advance:

Mysqladmin Create VPopmail

Mysql -u root -p

Mysql> Use mysql

MySQL> Grant SELECT, INSERT, UPDATE, DELETE, CREATE, /

Drop, File, INDEX, ALTER, Show Databases, /

Create Temporary Tables, LOCK TABLES ON *. * To "vpopmail" @ "localhost" Identified by "vpopmail" with /

MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;

mysql> flush privileges;

Here, a user name is VPOPMAIL and sets its password to vpopmail.

Third, installing vpopmail installation vpopmail is more important to pay attention, others will be simple: CD / USR / Ports / Mail / VPopmail

Make with_mysql = yes with_mysql_server = localhost /

WITH_MYSQL_USER = VPOPMAIL with_MYSQL_PASSWD = VPOPMAIL /

WITH_MYSQL_DB = VPOPMAIL with_MYSQL_LIMITS = YES

Make Install

Make clean

Vpopmail supports reading and writing of the user authentication database, which is the advantage of being able to use different servers to use different servers to process the user's increase and query operations. After installed VPopmail, you can find the vpopmail.mysql file in / usr / local / vpopmail / etc, which is just an empty file. This file requires you to join the two lines to tell VPopmail's read and write method information to the MySQL database, its format is as follows:

READ_SERVER | Read port_user | read_password | Database_name

Update_server | Update port | Update_user | Update_password | Database_name

The content of the first line is to read the access information of the database, and the second line is to update the access information of the database. After installing and vpopmail, we certainly need to test whether it can run normally, including data files that connect the MySQL database and normal operation QMAIL:

CD / USR / local / vpopmail / bin

./vadddomain test.com

./vadduser hd@test.com

The second step is to add a domain name to the system, and the third step is to add a user to the domain name. After entering the command, it prompts you to enter your password. The password for the domain name is the password used to maintain the MAST user in the domain. If there is no error message, which is congratulations, you have gone through most of the hard steps, I have already embarked on the bright avenue. There are many people who ask me to build a table structure in the database. In fact, everyone must know if you do the following:

User and libraries that have been updated before installation have been installed correctly in VPopMail.Mysql to set the correct database access information. Which is the corresponding table in the MySQL library. Fourth, install qmailadmin I have painful every time I add a user to SSH to the server, SU is vpopmail, and then enter the command. Maybe this is just the beginning of pain, you have to face the password, add mailbox forwarding, etc. 'advanced' or 'extra' user requirements. So, a cute management system came to save everyone in the water: QMAILADMIN. Everything above, it can help you. Let us use the universal ports:

CD / USR / ports / mail / qmailadmin

Make -dwith_modify_quota

Make Install Clean

It installs QMailAdmin's CGI-BIN to the qmailadmin directory of /usr/local/www/cgi-bin.default. Connect this directory to your CGI-bin directory with the ln -s command. Try your browser, a domain management account is Postmaster, log in to the domain password to go in. V. Installing and configuring Daemontools Installing I hate daemontools configuration, and I am very annoying which startup and monitoring Daemon's directory structure, but as the author of qmail is very good job. In addition, no one is worried about QMAIL, there is no one in the process of qmail, no one can know and restart, so we still come to configure this ugly little thing. Install it first: CD / usr / ports / sysutils / daemontools

Make Install Clean

The biggest feature of this tool is that the installation is easy to reach the limit, and the configuration is complex to the limit! Let's build a QMAIL service log directory and add permissions to qmail:

MKDIR -P / VAR / log / qmail / qmail-smtpd

MKDIR -P / VAR / log / qmail / qmail-pop3d

MKDIR -P / VAR / log / qmail / qmail-send

CHMOD -R 755 / VAR / LOG / QMAIL

Chown -r qmaill: Wheel / Var / log / qmail

Configuring SVSCAN preferably builds a script of the following:

#! / bin / sh

MKDIR / service

CHMOD 755 / Service

MKDIR / VAR / QMAIL / SuperVise

CHMOD 755 / VAR / QMAIL / SuperVise

MKDIR / VAR / QMAIL / SuperVise / qmail-smtpd

MKDIR / VAR / QMAIL / SuperVise / qmail-smtpd / log

CHMOD T / VAR / QMAIL / SuperVISE / qmail-smtpd

MKDIR / VAR / QMAIL / SuperVise / qmail-send

MKDIR / VAR / QMAIL / SuperVise / qmail-send / LOG

CHMOD T / VAR / QMAIL / SuperVise / qmail-send

MKDIR / VAR / QMAIL / SuperVise / qmail-pop3d

MKDIR / VAR / QMAIL / SuperVise / qmail-pop3d / log

CHMOD T / VAR / QMAIL / SuperVISE / QMAIL-POP3D

ln -s / var / qmail / supervise / * / service /

Below is the startup script of POP3D:

#! / bin / sh

EXEC / USR / LOCAL / BIN / TCPSERVER -H -R -V -C100 0 110 /

/ var / qmail / bin / qmail-popup host.domain.de /

/ usr / local / vpopmail / bin / vchkpw /

/ VAR / QMAIL / BIN / QMAIL-POP3D MAILDIR 2> & 1

Place this script in the / var / qmail / supervise / qmail-pop3d / RUN file, then: then start the POP3D Log Start Script:

#! / bin / sh

Exec / usr / local / bin / setuidgid qmaill / usr / local / bin / multiLog T S100000 N20 /

/ VAR / log / qmail / qmail-pop3d 2> & 1

In the RUN file in / var / qmail / supervise / qmail-pop3d / log, then execute: chmod 755 / var / qmail / supervise / qmail-pop3d / run

CHMOD 755 / VAR / QMAIL / SuperVise / qmail-pop3d / log

CHMOD 755 / VAR / QMAIL / SuperVise / qmail-pop3d / log / run

Start SMTPD startup script:

#! / bin / sh

Qmailduid = `/ usr / bin / id-u qmails`

Nofilesgid = `/ usr / bin / id -g qmails`

EXEC / USR / local / bin / tcpserver -p -r -x /

/us / ur cc/vpopmail/tc/tcp.smtp.cdb -u "$ qmailduid" /

-g "$ nofilesgid" -V -C100 0 SMTP RBLSMTPD /

/ VAR / QMAIL / BIN / QMAIL-SMTPD 2> & 1

Place the / var / qmail / supervise / qmail-smtpd run file. Pairing and SMTPD Log started script:

#! / bin / sh

Exec / usr / local / bin / setuidgid qmaill / usr / local / bin / multiLog T S100000 N20 /

/ VAR / log / qmail / qmail-smtpd 2> & 1

Place the / var / qmail / supervise / qmail-smtpd / log / in the RUN file. After that, execute:

CHMOD 755 / VAR / QMAIL / SuperVise / qmail-smtpd / run

CHMOD 755 / VAR / LOG / QMAIL / QMAIL-SMTPD / LOG

CHMOD 755 / VAR / LOG / qmail / qmail-smtpd / log / Run

Endless night, there is a qmail send! Will this script:

#! / bin / sh

EXEC / VAR / QMAIL / RC

Place the / var / qmail / supervise / qmail-send / in the RUN file. And put the following LOG startup script:

#! / bin / sh

Exec / usr / local / bin / setuidgid qmaill / usr / local / bin / multiLog T S100000 N20 /

/ VAR / log / qmail / qmail-send 2> & 1

Place the RUN file in / var / qmail / supervise / qmail-send / log, and finally dawn, we do the following command:

CHMOD 755 / VAR / QMAIL / SuperVise / qmail-send / Run

CHMOD R 755 / VAR / LOG / QMAIL / QMAIL-Send /

CHMOD R 755 / VAR / LOG / QMAIL / qmail-send / log / Run

I don't know if your finger is sour? In short, at this time, I will sing a karaoke, let your fingers take a break, boring SVSCAN is like the song we have to sing, is "conquering"! Setting the system boot script When the QMail.sh file in the system installation /us R / RAL/TC/rc.d is connected to the / var / qmail / rc file, but we need to start with SVSCAN, so we must first The original startup script is deleted, and a new startup script:

CD /usr/local/etc/rc.d

RM qmail.sh

Vi qmail.sh

The content of the script HD has been hard to help everyone copy:

#! / bin / sh

Case "$ 1" in

START)

echo -n "starting qmail: svscan"

IF CD / VAR / QMAIL / SuperVise; THEN

ENV - path = "/ var / qmail / bin: / usr / local / bin: / usr / bin: / bin" SVSCAN &

Echo $!> /VAR/Run/svscan.pid

Fi

echo "."

;

STOP)

echo -n "stopping qmail: svscan"

Kill `Cat / Var / Run / SVSCAN.PID`

echo -n "qmail"

SVC -DX / VAR / QMAIL / SuperVise / *

echo -n "logging"

SVC -DX / VAR / QMAIL / SuperVise / * / log

echo "."

;

STAT)

CD / VAR / QMAIL / SuperVise

svstat * * / log

;

DOQUEUE | ALRM)

Echo "Sending Alrm signal to qmail-send."

SVC -A / VAR / QMAIL / SuperVise / qmail-send

;

Queue)

/ VAR / QMAIL / BIN / QMAIL-QStat

/ VAR / QMAIL / BIN / QMAIL-QRead

;

Reload | HUP)

Echo "Sending Hup signal to qmail-send."

SVC -H / VAR / QMAIL / SuperVise / qmail-send

Echo "Sending Hup Signal to QMAIL-POP3D."

SVC -H / VAR / QMAIL / SuperVISE / QMAIL-POP3D

;

PAUSE)

echo "pausing qmail-send"

SVC -P / VAR / QMAIL / SuperVise / qmail-send

Echo "PAUSING qmail-smtpd"

SVC -P / VAR / QMAIL / SuperVise / qmail-smtpd

Echo "PAUSING qmail-pop3d"

SVC -P / VAR / QMAIL / SuperVISE / QMAIL-POP3D

;

CONT

echo "continuing qmail-send"

SVC-C / VAR / QMAIL / SuperVise / qmail-send

Echo "Continuing Qmail-SMTPD"

SVC-C / VAR / QMAIL / SuperVise / qmail-SMTPD

Echo "Continuing QMail-Pop3D"

SVC-C / VAR / QMAIL / SuperVise / QMAIL-POP3D

;

RESTART)

echo "Restarting QMail:"

echo "* stopping qmail-smtpd."

SVC -D / VAR / QMAIL / SuperVise / qmail-smtpd

echo "* sending qmail-send sigterm and restarting."

SVC -T / VAR / QMAIL / SuperVise / qmail-send

echo "* restarting qmail-smtpd."

SVC -U / VAR / QMAIL / SuperVise / qmail-smtpdecho "* sending qmail-pop3d sigterm and restarting."

SVC -T / VAR / QMAIL / SuperVISE / QMAIL-POP3D

;

CDB)

Tcprules /usr/local/vpopmail/tc/tcp.smtp.cdb /usr/local/vpopMail/etc/tcp.smtp.tmp <

/usr/local/vpopmail/etc/tcp.smtp

Chmod 644 /usr/local/vpopmail/tc/tcp.smtp*

Echo "reloaded /usr/local/vpopmail/tc/tcp.smtp."

;

*)

Echo "USAGE: $ 0 {start | stop | restart | doqueue | reload | stat | pause | cont | cdb | queue}"

EXIT 1

;

ESAC

EXIT 0

In your happiness, don't forget to give the startup script permission:

CHMOD X /USR /LOCAL/EtC/rc.d/qmail.sh

If you are still awake now, please start our great QMAIL. It has been quietly existed in our system to agree that it is standing:

/usr/local/etc/rc.d/qmail.sh start

If you find a problem after startup, please first check if Sendmail in the system can also be seen through the ps -ax command. If you can see it, it is recommended that you determine that you have updated it in this updated /etc/rc.conf. , Input to let the world see the bright command: reboot! It is necessary to know that the reincarnation is inevitable, the emperor can go to my house tomorrow! Sixth, tips, please remember: All questions will appear to the / var / local / maillog file first view the log. There are many friends who have problems with SMTP. I personally think that SMTP certification is a good idea, but qmail gives us a more fun way to prevent SMTP abuse. After installing the system, don't have an email, you first use the system's SMTP service to send a message. If the send purpose of the message is not the mailbox within the domain, you will get an error from the server:

553 Sorry, That Domain isn't in my list of allowed rcpthosts (# 5.7.1)

Here is that this SMTP server does not place your target address domain into the list of allowed delivery. If you are receiving an email now, you will find it when you send it, everything is normal! Oh, is it very fun? Here is a technology, that is, when you receive a message via POP3, your IP address will be recorded, you can send an email to other domains when you use SMTP, and this IP can be used. It is 30 minutes. If you want to change this time, modify the value of the RelayClear variable in the makefile when compiling VPOPMAIL. There are many ways to patch QMAIL's SMTP to use vpopmail's checkpassword to make SMTP verification. The reason I don't like this is mainly: This requires complete change of QMAIL's SMTPD code, and if the system is upgraded, it will not be available. This will use SMTP certification methods, and so now in the agreement is actually a standard agreement I have a lot of machines. I need to use SMTPD services, but now most of the SMTP clients, by they are command lines and programs. The interface does not support the authentication SMTP Implication So this article uses the user authentication of SMTPD no longer discussed in depth, and another security guarantee method for qmail vpopmail is used. If you have a good way, please tell me. Original URL: http://journal.cnfug.org/issue9/000052.html Note: Please retain the author information and indicate the author's information (Chinese Freebsd User Group http://www.cnfug.org)

转载请注明原文地址:https://www.9cbs.com/read-89502.html

New Post(0)