パッチの場所
http://qmail.org/moni.csi.hu/pub/glibc-2.3.1/

ローカルタイムのパッチを当てる(このURLはIEでは閲覧できません。)
wget http://www.jms1.net/qmail/qmail-date-localtime.patch

cd qmail-1.03/

ローカル時刻
patch -p1 < ../qmail-1.03.qmail_local.patch

patch -p1 < ../qmail-1.03.errno.patch

----------------------------------------------------------------------
インストール先のディレクトリを作る
----------------------------------------------------------------------

mkdir /var/qmail
groupadd nofiles
useradd -g nofiles -d /var/qmail/alias -s /bin/false alias
useradd -g nofiles -d /var/qmail -s /bin/false qmaild
useradd -g nofiles -d /var/qmail -s /bin/false qmaill
useradd -g nofiles -d /var/qmail -s /bin/false qmailp
groupadd qmail
useradd -g qmail -d /var/qmail -s /bin/false qmailq
useradd -g qmail -d /var/qmail -s /bin/false qmailr
useradd -g qmail -d /var/qmail -s /bin/false qmails

----------------------------------------------------------------------
コンパイルする
----------------------------------------------------------------------

make setup check

ドメインを指定して
./config-fast acoustype.com

----------------------------------------------------------------------
設定ファイルの確認
----------------------------------------------------------------------

cd /var/qmail/control

//ダブルバウンスメール破棄
touch /var/qmail/control/doublebounceto

//受信最大容量1MB
echo "1024000" > /var/qmail/control/databytes

//queue保存期間 1日
echo "86400" > /var/qmail/control/queuelifetime

[defaultdomain]
acoustype.com

[locals]
localhost
acoustype.com

[me]
acoustype.com

[plusdomain]
acoustype.com

[rcpthosts]
localhost
acoustype.com

----------------------------------------------------------------------
エイリアスの設定
----------------------------------------------------------------------

(例1)

cd /var/qmail/alias

touch .qmail-postmaster .qmail-mailer-daemon .qmail-root .qmail-anonymous .qmail-nobody

chmod 644 .qmail*

(例2 ****@****.com宛にシステムメールが届く)

cd /var/qmail/alias

echo "****@****.com" > .qmail-root
echo "****@****.com" > .qmail-nobody
echo "****@****.com" > .qmail-anonymous
echo "****@****.com" > .qmail-mailer-daemon

chmod 644 .qmail*

----------------------------------------------------------------------
起動スクリプトの用意
----------------------------------------------------------------------

cp /var/qmail/boot/home /var/qmail/rc

----------------------------------------------------------------------
Maildirに対応させる
----------------------------------------------------------------------

/var/qmail/rcを編集

vi /var/qmail/rc

qmail-start ./Mailbox splogger qmail

qmail-start ./Maildir/ splogger qmail

----------------------------------------------------------------------
Maildirを作る
----------------------------------------------------------------------

/var/qmail/bin/maildirmake ~alias/Maildir

chown -R alias /var/qmail/alias/Maildir

/var/qmail/bin/maildirmake ~/Maildir

/var/qmail/bin/maildirmake /etc/skel/Maildir

----------------------------------------------------------------------
qmailの起動コマンド
----------------------------------------------------------------------

/bin/csh -cf /var/qmail/rc &

----------------------------------------------------------------------
sendmailとqmailを差し替える
----------------------------------------------------------------------
デフォルトでインストールされているsendmailは一応そのままにしておく

cd /usr/sbin

rm -f sendmail.org

mv sendmail sendmail.org

chmod 0 sendmail.org

ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail

chmod 755 /var/qmail/bin/sendmail

----------------------------------------------------------------------
テスト送信
----------------------------------------------------------------------

echo to: ****@****.com | /var/qmail/bin/qmail-inject

--------------------------------------------------------------------------------
[tcpserverのインストール]
--------------------------------------------------------------------------------

cd ucspi-tcp-0.88/

patch < ../ucspi-tcp-0.88.errno.patch

make

make setup check

以下のコマンドで[qmaildのUID]と[nofilesのGID]を調べておく

id qmaild

uid=520(qmaild) gid=519(nofiles) 所属グループ=519(nofiles)

--------------------------------------------------------------------------------
[vpopmailのインストール] - MySQL
--------------------------------------------------------------------------------
http://sourceforge.net/projects/vpopmail/

パーミッションの変更
chown -R root.root vpopmail-5.4.25

cd vpopmail-5.4.25

ユーザーとグループの追加

userdel -r postfix
groupdel postfix

groupadd -g 89 vchkpw
useradd -g vchkpw -u 89 vpopmail

./configure \
--enable-incdir=/usr/local/mysql/include/mysql \
--enable-libdir=/usr/local/mysql/lib/mysql \
--enable-roaming-users \
--enable-relay-clear-minutes=15 \
--enable-logging=y \
--disable-ip-alias-domains \
--disable-passwd \
--enable-clear-passwd \
--disable-domain-quotas \
--enable-auth-module=mysql \
--disable-many-domains \
--enable-auth-logging \
--enable-sql-logging \
--enable-valias \
--disable-mysql-limits

./configure \
--enable-roaming-users \
--enable-relay-clear-minutes=15 \
--enable-logging=y

make

make install-strip

----------------------------------------------------------------------
MySQLの場合
----------------------------------------------------------------------

echo "localhost|0|vpopmailuser|vpoppasswd|vpopmail" > ~vpopmail/etc/vpopmail.mysql
chown vpopmail.vchkpw ~vpopmail/etc/vpopmail.mysql
chmod 640 ~vpopmail/etc/vpopmail.mysql

DB作成

CREATE DATABASE vpopmail;

GRANT select,insert,update,delete,create,drop ON vpopmail.* TO vpopmailuser@localhost IDENTIFIED BY 'vpoppasswd';

FLUSH PRIVILEGES;

----------------------------------------------------------------------
tcp.smtp データベースの作成
----------------------------------------------------------------------

vi /home/vpopmail/etc/tcp.smtp

127.:allow,RELAYCLIENT=""
192.168.1.0-255:allow,RELAYCLIENT=""
:allow

記述したらデータベースに変換
/usr/local/bin/tcprules /home/vpopmail/etc/tcp.smtp.cdb /home/vpopmail/etc/tcp.smtp.tmp < /home/vpopmail/etc/tcp.smtp

----------------------------------------------------------------------
POP Before SMTPのお掃除(15分で掃除)をcronで
----------------------------------------------------------------------

crontab -e

*/15 * * * * /home/vpopmail/bin/clearopensmtp 2>&1 > /dev/null

--------------------------------------------------------------------------------
[autoresponderのインストール]
--------------------------------------------------------------------------------

cd autorespond-2.0.4

make

make install

--------------------------------------------------------------------------------
[ezmlm(メーリングリスト)のインストール]
--------------------------------------------------------------------------------

----------------------------------------------------------------------
所有者の変更
----------------------------------------------------------------------

chown -R root:root ezmlm-0.53
chown -R root:root ezmlm-idx-0.444

----------------------------------------------------------------------
パッチをコピーする
----------------------------------------------------------------------

mv -f ezmlm-idx-0.444/* ezmlm-0.53/

cd ezmlm-0.53

----------------------------------------------------------------------
パッチをあてる
----------------------------------------------------------------------

patch < idx.patch

----------------------------------------------------------------------
一様パーミッションを変更
----------------------------------------------------------------------

chmod -R 755 *

----------------------------------------------------------------------
コンパイル
----------------------------------------------------------------------

make clean

make

make man

make ja

make setup

--------------------------------------------------------------------------------
[maildropのインストール]
--------------------------------------------------------------------------------

http://www.courier-mta.org/maildrop/

./configure \
--enable-syslog=1 \
--enable-maildrop-uid=vpopmail \
--enable-maildrop-gid=vchkpw \
--enable-trusted-users=vpopmail \
--enable-trusted-groups=vchkpw

make
make install-strip
make install-man

--------------------------------------------------------------------------------
[qmailadminのインストール]
--------------------------------------------------------------------------------

cd /usr/local/src/qmail/qmailadmin-1.2.9

./configure \
--enable-htmldir=/home/vpopmail/public_html \
--enable-cgibindir=/home/vpopmail/public_html \
--enable-cgipath=/~vpopmail/qmailadmin.cgi \
--enable-imagedir=/home/vpopmail/public_html/images/qmailadmin \
--enable-imageurl=/~vpopmail/images/qmailadmin \
--enable-modify-quota \
--enable-modify-spam \
--enable-spam-command="|/var/qmail/bin/preline /usr/local/bin/maildrop /etc/mailfilter" \
--enable-help

./configure \
--enable-htmldir=/home/vpopmail/public_html \
--enable-cgibindir=/home/vpopmail/public_html \
--enable-cgipath=/~vpopmail/qmailadmin.cgi \
--enable-imagedir=/home/vpopmail/public_html/images/qmailadmin \
--enable-imageurl=/~vpopmail/images/qmailadmin \
--enable-modify-quota

make

make install-strip

----------------------------------------------------------------------
拡張子[.cgi]をつける
----------------------------------------------------------------------

rm -f ~vpopmail/public_html/qmailadmin.cgi

cp -fp ~vpopmail/public_html/qmailadmin ~vpopmail/public_html/qmailadmin.cgi

rm -f ~vpopmail/public_html/qmailadmin

vi /home/vpopmail/public_html/.htaccess

DirectoryIndex qmailadmin.cgi

----------------------------------------------------------------------
qmailadmin-help
----------------------------------------------------------------------

mkdir /home/vpopmail/public_html/images/qmailadmin/help

cp -rp * /home/vpopmail/public_html/images/qmailadmin/help

vi /home/vpopmail/public_html/images/qmailadmin/help/.htaccess

DirectoryIndex index.html

----------------------------------------------------------------------
ドメインを登録
----------------------------------------------------------------------

cd ~vpopmail/bin

./vadddomain acoustype.jp

--------------------------------------------------------------------------------
qmail 起動スクリプト
--------------------------------------------------------------------------------

----------------------------------------------------------------------
viでファイル作成し、以下の点線内のスクリプトを記述
----------------------------------------------------------------------

vi /etc/rc.d/init.d/qmail

----------------------------------------------------------------------
事前に調べておいた[qmaildのUID]と[nofilesのGID]を書き換える
----------------------------------------------------------------------

id qmaild

uid=520(qmaild) gid=519(nofiles) 所属グループ=519(nofiles)

#Vsmtp
/usr/local/bin/tcpserver -H -R -l acoustype.jp -v -x \
/home/vpopmail/etc/tcp.smtp.cdb -u 520 -g 519 0 smtp \
/var/qmail/bin/qmail-smtpd 2>&1 | \
/var/qmail/bin/splogger smtpd 3 &

#Vpop
/usr/local/bin/tcpserver -H -R -l acoustype.jp -v 0 pop3 \
/var/qmail/bin/qmail-popup acoustype.jp \
/home/vpopmail/bin/vchkpw \
/var/qmail/bin/qmail-pop3d Maildir 2>&1 | \
/var/qmail/bin/splogger pop3d 3 &

----------------------------------------------------------------------
パーミッションの変更
----------------------------------------------------------------------

chmod 755 /etc/rc.d/init.d/qmail

------------------------------------------------------------
通常版
------------------------------------------------------------

#!/bin/sh
#
# qmail This shell script takes care
# of starting and stopping qmail.
#
# chkconfig: 2345 80 30
# description: Starts and stops qmail.

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

# See how we were called.
case "$1" in

start)
echo -n "Starting qmail: "

# Using splogger to send the log through syslog.
exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start ./Maildir/ splogger qmail &

# Start smtpd
/usr/local/bin/tcpserver -H -R -l acoustype.com -v -x \
/home/vpopmail/etc/tcp.smtp.cdb -u 504 -g 503 0 smtp \
/var/qmail/bin/qmail-smtpd 2>&1 | \
/var/qmail/bin/splogger smtpd 3 &

# Start pop3d
/usr/local/bin/tcpserver -H -R -l acoustype.com -v 0 pop3 \
/var/qmail/bin/qmail-popup acoustype.com \
/home/vpopmail/bin/vchkpw \
/var/qmail/bin/qmail-pop3d Maildir 2>&1 | \
/var/qmail/bin/splogger pop3d 3 &

echo
touch /var/lock/subsys/qmail
;;
stop)
echo -n "Shutting down qmail: "
killproc qmail-send
killproc tcpserver
echo
rm -f /var/lock/subsys/qmail
echo ""
;;
restart)
echo -n "Restarting qmail: "
$0 stop
$0 start
echo "done."
;;
cdb)
/usr/local/bin/tcprules /home/vpopmail/etc/tcp.smtp.cdb /home/vpopmail/etc/tcp.smtp.tmp < /home/vpopmail/etc/tcp.smtp
echo "done."
;;
*)
echo "Usage: qmail {start|stop|restart|cdb}"
exit 1

esac

exit 0

------------------------------------------------------------
qmail-scanner-queue.pl版
------------------------------------------------------------

#!/bin/sh
#
# qmail This shell script takes care
# of starting and stopping qmail.
#
# chkconfig: 2345 80 30
# description: Starts and stops qmail.

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"
export QMAILQUEUE

# See how we were called.
case "$1" in

start)
echo -n "Starting qmail: "

# Using splogger to send the log through syslog.
exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start ./Maildir/ splogger qmail &

# Start smtpd
/usr/local/bin/tcpserver -H -R -l acoustype.com -v -x \
/home/vpopmail/etc/tcp.smtp.cdb -u 504 -g 503 0 smtp \
/var/qmail/bin/qmail-smtpd 2>&1 | \
/var/qmail/bin/splogger smtpd 3 &

# Start pop3d
/usr/local/bin/tcpserver -H -R -l acoustype.com -v 0 pop3 \
/var/qmail/bin/qmail-popup acoustype.com \
/home/vpopmail/bin/vchkpw \
/var/qmail/bin/qmail-pop3d Maildir 2>&1 | \
/var/qmail/bin/splogger pop3d 3 &

echo
touch /var/lock/subsys/qmail
;;
stop)
echo -n "Shutting down qmail: "
killproc qmail-send
killproc tcpserver
echo
rm -f /var/lock/subsys/qmail
echo ""
;;
restart)
echo -n "Restarting qmail: "
$0 stop
$0 start
echo "done."
;;
cdb)
/usr/local/bin/tcprules /home/vpopmail/etc/tcp.smtp.cdb /home/vpopmail/etc/tcp.smtp.tmp < /home/vpopmail/etc/tcp.smtp
echo "done."
;;
*)
echo "Usage: qmail {start|stop|restart|cdb}"
exit 1

esac

exit 0

----------------------------------------------------------------------
自動起動に登録
----------------------------------------------------------------------
chkconfig --add qmail

--------------------------------------------------------------------------------
Qmail-Scannerのインストール
--------------------------------------------------------------------------------

http://www.atmarkit.co.jp/flinux/rensai/qmail08/qmail08c.html

qmail-scanner-1.25.gz
http://qmail-scanner.sourceforge.net/

maildrop-1.8.0.tar.bz2
http://prdownloads.sourceforge.net/courier

perlモジュール
cpanでインストール
perl -MCPAN -e -shell

install Time::HiRes
install DB_File
install Sys::Syslog

ウイルスソフト(個人利用はフリー)
AntiVir Workstation
AntiVir Mailserver

http://www.hbedv.com
http://www.hbedv.com/en/support/unix_private_registration/index.html

----------------------------------------------------------------------

/usr/lib/AntiVir/antivir --update

configure: /usr/lib/AntiVir/configantivir

Automatic Internet Updater
==========================
start: /usr/lib/AntiVir/avupdater start
stop: /usr/lib/AntiVir/avupdater stop
check: /usr/lib/AntiVir/avupdater status

----------------------------------------------------------------------

echo $LANG

export LANG=ja_JP.EUC

suidperlのパーミッションの確認4711になっていればOK
ls -l /usr/bin/suidperl

なってなければ
chmod 4711 /usr/bin/suidperl

----------------------------------------------------------------------

./configure --install --domain acoustype.jp

多分ユーザーとグループを追加しろと怒られるので

groupadd qscand
useradd -c "Qmail-Scanner Account" -g qscand -s /bin/false qscand

再度
./configure --install --domain acoustype.jp

----------------------------------------------------------------------
qmail 起動スクリプトに追加しておく
----------------------------------------------------------------------

#!/bin/sh
#
# qmail: /var/qmail
PATH=/var/qmail/bin:/usr/local/bin:/bin:/usr/bin

QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"
export QMAILQUEUE

[ -f /var/qmail/rc ] || exit 0

case "$1" in
start)
# Start daemons.
echo "Starting qmail."

#qmail
/bin/csh -cf /var/qmail/rc &

#Vsmtp
/usr/local/bin/tcpserver -H -R -l acoustype.com -v -x \
/home/vpopmail/etc/tcp.smtp.cdb -u 520 -g 519 0 smtp \
/var/qmail/bin/qmail-smtpd 2>&1 | \
/var/qmail/bin/splogger smtpd 3 &

#Vpop
/usr/local/bin/tcpserver -H -R -l acoustype.com -v 0 pop3 \
/var/qmail/bin/qmail-popup acoustype.com \
/home/vpopmail/bin/vchkpw \
/var/qmail/bin/qmail-pop3d Maildir 2>&1 | \
/var/qmail/bin/splogger pop3d 3 &

echo
touch /var/lock/qmail
;;
stop)
# Stop daemons.
echo "Shutting down qmail."
PID=`/bin/ps -aefw | grep qmail | awk '{print $2}'`
if [ ! -z "$PID" ] ; then
/bin/kill ${PID} 1> /dev/null 2>&1
fi
echo
rm -f /var/lock/qmail
;;
*)
echo "Usage: S99qmail {start|stop}"
exit 1
esac

exit 0

----------------------------------------------------------------------
動作チェック
----------------------------------------------------------------------

qmail-scannerの展開したソースフォルダに移動

cd /usr/local/src/qmail/qmail-scanner-1.25

./contrib/test_installation.sh -doit

root当てにメールが届けばOK

----------------------------------------------------------------------
拒否する添付ファイルなどの設定
----------------------------------------------------------------------

vi /var/spool/qmailscan/quarantine-attachments.txt

.bat 0 COMMAND.COM batch file
.com 0 Non relocable MSDOS executable binary
.pif 0 Windows Program Information Files
.scr 0 Screen Saver

変更が完了したら以下を実行してデータベースに反映させる。

/var/qmail/bin/qmail-scanner-queue.pl -g

queue-fix

queue-fixはqmailのキューの整合性がくずれた場合に、復旧する為のツール。
queueディレクトリを移動する場合にも使える。

http://www.netmeridian.com/e-huss/queue-fix.tar.gz

make

./queue-fix -i /var/qmail/queue

------------------------------
qmail:queue-fix-1.4 make時にエラー

error.hの3行目の「extern int errno;」を「#include <errno.h>」に修正
------------------------------

qmail でキューにたまったメールを直ちに配送する方法

qmail でキューにたまったメールを直ちに配送する方法

qmail-send に ALRM シグナルを送る.

qmail-send のプロセス番号が 109 のとき

kill -ALRM 109

参考元

qmail でキューにたまったメールを削除

qmhandle 1.3 2007-05-31

ダウンロード

参考元

.qmail-default

| /home/vpopmail/bin/vdelivermail '' bounce-no-mailbox
| /home/vpopmail/bin/vdelivermail '' delete

echo "| /home/vpopmail/bin/vdelivermail '' delete" > .qmail-default

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です