もくじ
環境
- CentOS6.9
必要なユーザの作成
su - groupadd nofiles groupadd qmail useradd -g nofiles -s /sbin/nologin -u 490 alias -m -d /var/qmail/alias -k /dev/null useradd -g nofiles -d /var/qmail -s /sbin/nologin -u 491 -M qmaild useradd -g nofiles -d /var/qmail -s /sbin/nologin -u 492 -M qmaill useradd -g nofiles -d /var/qmail -s /sbin/nologin -u 493 -M qmailp useradd -g qmail -d /var/qmail -s /sbin/nologin -u 494 -M qmailq useradd -g qmail -d /var/qmail -s /sbin/nologin -u 495 -M qmailr useradd -g qmail -d /var/qmail -s /sbin/nologin -u 496 -M qmails
ソースファイルの取得
# cd /usr/local/src # wget https://www.yuulinux.tokyo/httpdocs/delivery/qmailSet.zip # unzip qmailSet.zip ------------------------------------------------------------------------------ wget http://tomclegg.net/qmail/qmail-1.03.tar.gz wget http://tomclegg.net/qmail/qmail-smtpd-auth-0.31.tar.gz wget http://www.itheart.com/phpgw/qmail-date-localtime.patch wget http://tomclegg.net/qmail/qmail-remote-auth.patch wget http://www.qmail.org/qmail-smtpd-relay-reject wget http://www.qmail.org/moni.csi.hu/pub/glibc-2.3.1/qmail-1.03.errno.patch wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz wget http://www.qmail.org/rpms/patches/ucspi-tcp-0.88.errno.patch wget http://cr.yp.to/software/ezmlm-0.53.tar.gz wget http://ezmlm.sericyb.com.au/archive/5.1.2/ezmlm-idx-5.1.2.tar.gz wget http://notes.sagredo.eu/files/qmail/tar/autorespond-2.0.5.tar.gz https://sourceforge.net/projects/vpopmail/postdownload # mv vpopmail-5.4.33.tar.gz /usr/local/src/ ------------------------------------------------------------------------------
tcpserverのインストール
# tar zxvf ucspi-tcp-0.88.tar.gz # cd ucspi-tcp-0.88 # patch < /usr/local/src/ucspi-tcp-0.88.errno.patch # make && make setup check ./load instcheck hier.o auto_home.o unix.a byte.a ./install ./instcheck
qmailのインストール
mkdir /var/qmail/ cd /var/qmail tar zxvf /usr/local/src/qmail-1.03.tar.gz tar zxvf /usr/local/src/qmail-smtpd-auth-0.31.tar.gz # mv qmail-smtpd-auth-0.31/* qmail-1.03/ mv: overwrite `qmail-1.03/CHANGES'? ye
yum install patch gcc cd qmail-1.03 patch -p1 < /usr/local/src/qmail-date-localtime.patch patch < auth.patch patch < /usr/local/src/qmail-smtpd-relay-reject patch < /usr/local/src/qmail-1.03.errno.patch make setup check
# hostname example.net # hostname example.net
設定
# ./config-fast `hostname`
vpopメールのインストール
cd /usr/local/src/ tar zxvf /usr/local/src/vpopmail-5.4.33.tar.gz cd vpopmail-* groupadd vchkpw useradd -g vchkpw -s /sbin/nologin -d /var/qmail/vpopmail -M vpopmail chown vpopmail:vchkpw /var/qmail/vpopmail/ ./configure --enable-loggin=y --enable-roaming-users=y --enable-relay-clear-minutes=10 --enable-tcpserver-file=/var/qmail/vpopmail/etc/tcp.smtp --enable-clear-passwd=n vpopmail 5.4.33 Current settings --------------------------------------- vpopmail directory = /var/qmail/vpopmail domains directory = /var/qmail/vpopmail/domains uid = 500 gid = 502 roaming users = ON --enable-roaming-users tcpserver file = /var/qmail/vpopmail/etc/tcp.smtp open_smtp file = /var/qmail/vpopmail/etc/open-smtp rebuild tcpserver file = ON --enable-rebuild-tcpserver-file (default) password learning = OFF --disable-learn-passwords (default) md5 passwords = ON --enable-md5-passwords (default) file locking = ON --enable-file-locking (default) vdelivermail fsync = OFF --disable-file-sync (default) make seekable = ON --enable-make-seekable (default) clear passwd = OFF --disable-clear-passwd user dir hashing = ON --enable-users-big-dir (default) address extensions = OFF --disable-qmail-ext (default) ip alias = OFF --disable-ip-alias-domains (default) onchange script = OFF --disable-onchange-script (default) domain quotas = OFF --disable-domainquotas (default) auth module = cdb --enable-auth-module=cdb (default) auth inc = -Icdb auth lib = system passwords = OFF --disable-passwd (default) pop syslog = show only failed attempts --enable-logging=e (default) auth logging = ON --enable-auth-logging (default) spamassassin = OFF --disable-spamassassin (default) maildrop = OFF --disable-maildrop (default)
make install-strip chown root:root /var/qmail/vpopmail/bin/vchkpw chmod 4755 /var/qmail/vpopmail/bin/vchkpw useradd -s /sbin/nologin vpopmail groupadd vpopmail chown -R vpopmail:vpopmail /var/qmail/vpopmail/etc/ mkdir /var/qmail/vpopmail chmod 755 /var/qmail/vpopmail mkdir -p /var/qmail/vpopmail/etc
リレーの設定
# vi /var/qmail/vpopmail/etc/tcp.smtp 127.:allow,RELAYCLIENT="" :allow
繁栄
# tcprules /var/qmail/vpopmail/etc/tcp.smtp.cdb /var/qmail/vpopmail/etc/tcp.smtp.tmp < /var/qmail/vpopmail/etc/tcp.smtp
メールアドレスの設定
ドメインの作成
# /var/qmail/vpopmail/bin/vadddomain example.net Please enter password for postmaster: enter password again:
ユーザの作成
# /var/qmail/vpopmail/bin/vadduser yuu@example.net
qmailの起動スクリプト設定
Postfixの停止と無効化
# /etc/rc.d/init.d/postfix status # /etc/rc.d/init.d/postfix stop # chkconfig postfix off
qmail起動スクリプト作成
# vi /etc/init.d/qmail #!/bin/bash # # qmail # # chkconfig: 2345 80 30 # description: qmail start/stop script # Source function library. . /etc/rc.d/init.d/functions PATH=/var/qmail/bin:/usr/local/bin:/bin:/usr/bin [ -f /var/qmail/rc ] || exit 0 start() { # Start daemons. if [ -z $(/sbin/pidof qmail-send) ]; then echo -n "Starting qmail" # qmail csh -cf '/var/qmail/rc &' 2>&1 > /dev/null # SMTP(21) tcpserver -qv -l0 -HR -u id -u qmaild -g id -g qmaild -x /var/qmail/vpopmail/etc/tcp.smtp.cdb 0 smtp fixcrio qmail-smtpd hostname /bin/true 2>&1| splogger smtp & # SMTP(587) tcpserver -qv -l0 -HR -u id -u qmaild -g id -g qmaild -x /var/qmail/vpopmail/etc/tcp.smtp.cdb 0 587 fixcrio qmail-smtpd hostname /bin/true 2>&1|splogger smtp & # POP3 tcpserver -H -R -l $HOSTNAME -v 0 pop3 /var/qmail/bin/qmail-popup $HOSTNAME /var/qmail/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir 2>&1 | /var/qmail/bin/splogger pop3 & RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/qmail return $RETVAL else echo "qmail is already started" fi } stop() { # Stop daemons. if [ ! -z $(/sbin/pidof qmail-send) ]; then echo -n "Shutting down qmail" /bin/kill $(/sbin/pidof tcpserver) /bin/kill $(/sbin/pidof qmail-send) until [ -z $(/sbin/pidof qmail-send) ] && [ -z $(/sbin/pidof tcpserver) ]; do :; done echo rm -f /var/lock/subsys/qmail else echo "qmail is not running" fi } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) if [ ! -z $(/sbin/pidof qmail-send) ] ; then echo -n "qmail (pid" echo -n " /sbin/pidof qmail-send" echo -n " /sbin/pidof tcpserver" echo ") is running..." else echo "qmail is stopped" fi ;; *) echo "Usage: qmail {start|stop|restart|status}" exit 1 esac exit 0
# chmod +x /etc/init.d/qmail # cp /var/qmail/boot/home /var/qmail/rc # sed -i 's/Mailbox/Maildir\//g' /var/qmail/rc # chmod o+w /var/qmail/rc
起動開始
# /etc/rc.d/init.d/qmail start Starting qmail
ここでメールクライアントからメールを送信します。
確認
# ls -laht /var/qmail/vpopmail/domains/example.net/yuu/Maildir/new/ total 12K drwx------ 2 vpopmail vchkpw 4.0K Nov 8 13:19 . -rw------- 1 vpopmail vchkpw 1.4K Nov 8 13:19 1541650784.8395.example.net,S=1407 drwx------ 5 vpopmail vchkpw 4.0K Nov 8 13:17 ..
メールが届いています。
qmailadmin
yum install nkf cd /usr/local/src/ wget http://cr.yp.to/software/ezmlm-0.53.tar.gz wget http://ezmlm.sericyb.com.au/archive/5.1.2/ezmlm-idx-5.1.2.tar.gz
tar zxvf ezmlm-0.53.tar.gz tar zxvf ezmlm-idx-5.1.2.tar.gz mv -f /usr/local/src/ezmlm-idx-5.1.2/* /usr/local/src/ezmlm-0.53/ cd ezmlm-0.53 patch < idx.patch make && make setup
wget http://notes.sagredo.eu/files/qmail/tar/autorespond-2.0.5.tar.gz tar xzf autorespond-2.0.5.tar.gz cd /usr/local/src/autorespond-*
# vi /usr/local/src/autorespond-2.0.5/autorespond.c fprintf(fdm,"Date: %u %s %u %02u:%02u:%02u -0000\nMessage-ID: <%lu.%u.blah>\n" ,dt->tm_mday,montab[dt->tm_mon],dt->tm_year+1900,dt->tm_hour,dt->tm_min,dt->tm_sec,msgwhen,getpid() ); mfp = fopen( msg, "rb" ); ↓変更 fprintf(fdm,"Date: %u %s %u %02u:%02u:%02u -0000\nMessage-ID: <%lu.%u.blah>\n" ,dt->tm_mday,montab[dt->tm_mon],dt->tm_year+1900,dt->tm_hour,dt->tm_min,dt->tm_sec,msgwhen,getpid() ); fprintf(fdm,"Content-Type: text/plain; charset=\"ISO-2022-JP\"\n" ); mfp = fopen( msg, "rb" );
# gcc -Wall -o autorespond autorespond.c # cp autorespond /var/qmail/bin/
mv qmailadmin-1.2.16.tar.gz /usr/local/src/ tar xvzf qmailadmin-1.2.16.tar.gz cd qmailadmin-* ./configure --enable-htmldir=/var/www/html --enable-cgibindir=/var/www/cgi-bin --enable-cgipath=/cgi-bin/qmailadmin --enable-imagedir=/var/www/icons/qmailadmin --enable-imageurl=/icons/qmailadmin --enable-ezmlmdir=n make && make install-strip
# vi /etc/httpd/conf.d/qmailadmin.conf <VirtualHost *:80> ServerName example.net DocumentRoot /var/www/html </VirtualHost
# vi /etc/httpd/conf/httpd.conf <Directory "/var/www/icons"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> ↓ <Directory "/var/www/icons"> Options Indexes MultiViews FollowSymLinks #AllowOverride None AllowOverride AuthConfig Limit Order allow,deny Allow from all </Directory>
# httpd -t # service httpd restart
http://ドメイン名/cgi-bin/qmailadmin
- ユーザアカウント
postmaster - ドメイン
example.net - パスワード
パスワードを入力
qmail設定ファイル
# ls -laht /var/qmail/control total 28K drwxr-xr-x 13 root qmail 4.0K Nov 8 13:18 .. drwxr-xr-x 2 root qmail 4.0K Nov 8 13:16 . -rw-r--r-- 1 root root 0 Nov 8 13:16 locals -rw-r--r-- 1 root root 28 Nov 8 13:16 virtualdomains -rw-r--r-- 1 root root 14 Nov 8 13:16 rcpthosts -rw------- 1 root root 0 Nov 8 13:15 locals.lock -rw------- 1 root root 0 Nov 8 13:15 rcpthosts.lock -rw------- 1 root root 0 Nov 8 13:15 virtualdomains.lock -rw-r--r-- 1 root root 14 Nov 8 11:24 plusdomain -rw-r--r-- 1 root root 14 Nov 8 11:24 defaultdomain -rw-r--r-- 1 root root 14 Nov 8 11:24 me
ファイル | 初期値 | 役割 | 記述例 |
locals | me | qmailが受信するメールホスト名、ドメイン名 | |
me *必須 | me | qmailが稼働するホストのFQDN | exaple.net |
virtualdomains | none | example.net:example.net | |
rcpthosts *必須 | none | qmailが受信するメールホスト名、ドメイン名 | exaple.net |
plusdomain | me | 追加ドメイン名 | yuutest.space |
defaultdomain * | me | メールの送信先に(TO:)がない時に補完するドメイン名 | yuutest.space |
他にも追加出来るファイルは20種類ぐらいあるので、マニュアルを見て要件に合わせて追加していく。