Second Instance of Qmail for Disclaimer: Difference between revisions
| (4 intermediate revisions by the same user not shown) | |||
| Line 39: | Line 39: | ||
echo 255 > /usr/src/ | echo 255 > /usr/src/qmail2/qmail-1.03/conf-spwan | ||
echo 211 > /usr/src/ | echo 211 > /usr/src/qmail2/qmail-1.03/conf-split | ||
| Line 57: | Line 57: | ||
make setup check | make setup check | ||
./config-fast $Hostname | ./config-fast $Hostname | ||
Where $Hostname is the Host name of the Server | |||
Now create additional Qmail control files and Daemons | Now create additional Qmail control files and Daemons | ||
== Control Files == | == Additional Qmail2 Control Files == | ||
cd /var/qmail2/control/ | cd /var/qmail2/control/ | ||
| Line 167: | Line 169: | ||
rpm –Uvh bglibs-1.022-1.i386.rpm ( get it from http://untroubled.org/bglibs/ ) | rpm –Uvh bglibs-1.022-1.i386.rpm ( get it from http://untroubled.org/bglibs/ ) | ||
or | |||
tar -xvfz bglibs-1.022-1.tar.gz | |||
cd bglibs-1.022-1 | |||
make | |||
make install | |||
tar xvzf altermime-0.3.6.tar.gz (get it from http://www.pldaniels.com/altermime/ ) | tar xvzf altermime-0.3.6.tar.gz (get it from http://www.pldaniels.com/altermime/ ) | ||
cd altermime-0.3. | cd altermime-0.3.6 | ||
make | |||
make install | |||
tar xvzf qmail-qfilter-2.1.tar.gz (http://untroubled.org/qmail-qfilter/) | tar xvzf qmail-qfilter-2.1.tar.gz (http://untroubled.org/qmail-qfilter/) | ||
| Line 362: | Line 373: | ||
This should solve the issue | This should solve the issue | ||
2. Some time the Qmail-1 is not able to deliver mails to Qmail-2 instance due to /var/tmp/qmail-qfilter directory is not there or vanishes. So a script to check and create the directory with cron is created for taking care of this issue. | |||
The script is /usr/bin/check_qmail-qfilter_dir.sh | |||
#!/bin/sh | |||
DIRECTORY=/var/tmp/qmail-qfilter | |||
if [ ! -d "$DIRECTORY" ]; then | |||
mkdir -p $DIRECTORY; | |||
chmod 777 $DIRECTORY; | |||
chown -R root.qmail $Directory | |||
fi | |||
The cron entry is as follows | |||
*/5 * * * * /usr/bin/check_qmail-qfilter_dir.sh | |||
Latest revision as of 18:07, 20 January 2013
This document is part of Hindustan times implementation document talking about Qmail Disclaimer Integration with QMAIL Second Instance
Concept[edit]
Disclaimer on Qmail is Added to the Second Instance so that only Out going mails to different domains are uploaded with Common Signature / Disclaimer. This can be done for multiple domains too.
Implementation process[edit]
- Implement Qmail-2 , i.e Second Qmail Instance
- Define Qmail-send and Qmail-smtpd daemons
- Define 2nd Qmail smtp port ( say 900)
- Install Qmail-qfilter , altermime and bglibs to satisfy the requirement.
- Define Multiple domain's text and HTML disclaimer
- Integrate Qmail's both the instances
Second Instance of Qmail for Disclaimer[edit]
mkdir -p /var/qmail2
mkdir /usr/src/qmail2
cd /usr/src/qmail2
tar xvzf /downloads/qmailrocks/qmail-1.03.tar.gz ( Assuming that you have downloaded Qmailrocks earlier )
cd qmail-1.03
patch -p1 < /downloads/qmailrocks/patches/qmail-1.03.errno.patch
patch -p1 < /downloads/qmailrocks/patches/qmailqueue.patch
echo 255 > /usr/src/qmail2/qmail-1.03/conf-spwan
echo 211 > /usr/src/qmail2/qmail-1.03/conf-split
vi conf-qmail
( replace qmail with qmail2 )
Caution: This is very critical Step as, not doing do will cause the main Qmail instance will get over written .
And then Compile Qmail2 with
make setup check ./config-fast $Hostname
Where $Hostname is the Host name of the Server
Now create additional Qmail control files and Daemons
Additional Qmail2 Control Files[edit]
cd /var/qmail2/control/ echo ./Maildir/ > defaultdelivery echo 100 > concurrencyincoming echo 800000000 > qmail-smtpd-softlimit echo 3 > qmail-start-loglevel
Qmail2 Daemons[edit]
Now create qmail2-smtpd and qmail2-send daemons
Create /var/qmail2/rc
#!/bin/sh QLOG="`cat /var/qmail2/control/qmail-start-loglevel`" DEFD="`cat /var/qmail2/control/defaultdelivery`" exec env - PATH="/var/qmail2/bin:$PATH" LOGLEVEL="$QLOG" qmail-start "$DEFD"
Make it executable chmod 755 /var/qmail2/rc
Create supervise directories for Qmail2-send and Qmail2-smtpd and log directories
mkdir -p /var/qmail2/supervise/qmail2-smtpd/log mkdir -p /var/qmail2/supervise/qmail2-send/log mkdir -p /var/log/qmail2/qmail2-smtpd/ mkdir -p /var/log/qmail2/qmail2-send/ chown -R qmaill.nofiles /var/log/qmail2/
Daemon for Qmail2-send
create executable file /var/qmail2/supervise/qmail2-send/run
#!/bin/sh exec /var/qmail2/rc
once saved , make it executable via
chmod 755 /var/qmail2/supervise/qmail2-send/run
Log daemon for Qmail2-send
create executable file /var/qmail2/supervise/qmail2-send/log/run
#!/bin/sh exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t s10000000 n20 /var/log/qmail2/qmail2-send 2>&1
Daemon for Qmail2-smtpd
create executable file /var/qmail2/supervise/qmail2-smtpd/run
#!/bin/sh
QUID=`id -u qmaild`
QGID=`id -g qmaild`
MAXD=`head -1 /var/qmail2/control/concurrencyincoming`
HOST=`head -1 /var/qmail2/control/me`
SOFT=`head -1 /var/qmail2/control/qmail-smtpd-softlimit`
CDBF="/etc/tcp.smtp.cdb"
if [ -z "$QUID" -o -z "$QGID" -o -z "$MAXD" -o -z "$HOST" ]; then
echo QUID, QGID, MAXD, or HOST is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
exec /usr/local/bin/softlimit -m $SOFT \
/usr/local/bin/tcpserver -v \
-H \
-R \
-l $HOST \
-x $CDBF \
-c $MAXD \
-u $QUID \
-g $QGID \
0 \
900 \
/var/qmail2/bin/qmail-smtpd \
/var/qmail2/bin/auth_smtp /usr/bin/true 2>&1
Make it executable
Log daemon for Qmail2-smtpd
create executable file /var/qmail2/supervise/qmail2-smtpd/log/run
#!/bin/sh exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t s10000000 n20 /var/log/qmail2/qmail2-smtpd 2>&1
Make it executable
Now link these file to /service
ln -s /var/qmail2/supervise/qmail2-smtpd /service/ ln -s /var/qmail2/supervise/qmail2-send /service/
Restart the Qmail via inttab process
Testing of Qmail - Second instance[edit]
- telnet to port 900 and send the mail .
- check for logs /var/log/qmail2/qmail2-send/current or /var/log/qmail2/qmail2-smtpd/current
Disclaimer Related Implementation[edit]
cd /downloads/
rpm –Uvh bglibs-1.022-1.i386.rpm ( get it from http://untroubled.org/bglibs/ )
or
tar -xvfz bglibs-1.022-1.tar.gz
cd bglibs-1.022-1 make make install
tar xvzf altermime-0.3.6.tar.gz (get it from http://www.pldaniels.com/altermime/ )
cd altermime-0.3.6 make make install
tar xvzf qmail-qfilter-2.1.tar.gz (http://untroubled.org/qmail-qfilter/)
cd qmail-qfilter-2.1
vi qmail-qfilter.c
( change qmail into qmail2 )
------------------------------------------------------------------------------------------------------
#ifndef QMAIL_QUEUE
#define QMAIL_QUEUE "/var/qmail2/bin/qmail-queue"
#endif
------------------------------------------------------------------------------------------------------
make
make install
chmod 777 /usr/local/bin/qmail-qfilter
chown root:qmail /usr/local/bin/qmail-qfilter
vi /var/qmail2/bin/qmail-tail
#!/bin/sh exec /usr/local/bin/qmail-qfilter /var/qmail2/bin/qmail-disclaimer
chown root:qmail /var/qmail2/bin/qmail-tail
chmod 777 /var/qmail2/bin/qmail-tail
mkdir /var/qmail2/control/disclaimer/
cd /var/qmail2/control/disclaimer
vi hindustantimes.com.html
-----------------------------------------------------------------------------------------------------
<html>
<body>
IMPORTANT NOTICE:
"This email is confidential containing HT Media confidential information, may be
legally privileged, and is for the intended recipient only. Access, disclosure,
copying, distribution, or reliance on any of it by anyone else is prohibited and may
be a criminal offence. Please delete if obtained in error and email confirmation to
the sender."
Experience news. Like never before. Only on www.hindustantimes.com
</body>
</html>
-------------------------------------------------------------------------------------------------------
vi hindustantimes.com.txt
-------------------------------------------------------------------------------------------------------
IMPORTANT NOTICE:
"This email is confidential containing HT Media confidential information, may be
legally privileged, and is for the intended recipient only. Access, disclosure,
copying, distribution, or reliance on any of it by anyone else is prohibited and may
be a criminal offence. Please delete if obtained in error and email confirmation to
the sender."
Experience news. Like never before. Only on www.hindustantimes.com
------------------------------------------------------------------------------------------------------
chown root:qmail /var/qmail2/control/disclaimer/*
chmod 777 /var/qmail2/control/disclaimer/*
mkdir /var/tmp/qmail-qfilter
chown root:qmail /var/tmp/qmail-qfilter
chmod 777 /var/tmp/qmail-qfilter
vi /var/qmail2/bin/qmail-disclaimer
#!/bin/sh
INSPECT_DIR=/var/tmp/qmail-qfilter
if [ ! -f /var/qmail2/control/disclaimer/$QMAILHOST.txt ]
then
cat
exit 0
fi
EX_TEMPFAIL=31
EX_UNAVAILABLE=31
trap "rm -f /var/tmp/qmail-qfilter/in.$$" 0 1 2 3 15
cd $INSPECT_DIR || { echo Error: $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }
cat >$INSPECT_DIR/in.$$ || { echo Error: Cannot write to disk; exit $EX_TEMPFAIL; }
/usr/local/bin/altermime --input=$INSPECT_DIR/in.$$ \
--xheader="X-Disclaimer: $QMAILHOST" \
--disclaimer=/var/qmail2/control/disclaimer/$QMAILHOST.txt \
--disclaimer-html=/var/qmail2/control/disclaimer/$QMAILHOST.html || { echo Error: message rejected; exit $EX_UNAVAILABLE; }
cat $INSPECT_DIR/in.$$
rm in.$$
exit $?
chown root:qmail /var/qmail2/bin/qmail-disclaimer
chmod 777 /var/qmail2/bin/qmail-disclaimer
Activation of Qmail2[edit]
Changes on Qmail2-Send run file
vi /service/qmail2-smtpd/run
( add following line at the top )
#!/bin/sh QMAILQUEUE="/var/qmail2/bin/qmail-tail"; export QMAILQUEUE
Also Make sure the Qmail-smtpd is running on port 900 by
vi /etc/services
# Local services second-qmail 900/tcp
Integrate Qmail with Qmail2
vi /var/qmail/control/smtproutes
:127.0.0.1:900
Note: Then restart the qmail from /etc/inittab file.
Testing[edit]
- telnet and send mail via Qmail-2 , you should get the disclaimer
- Test via offline Client like Evolution , Outlook etc . You should get the mail with disclaimer attached .
Troubleshooting[edit]
1. QQ error while sending mails
Check the smtp logs , if find error like
/usr/local/bin/qmail-qfilter: error while loading shared libraries: libbg-sysdeps.so.1: cannot open shared object file: No such file or directory
Then
you have to link libbg-sysdeps.so.1 to /usr/lib
ln -s /usr/local/bglibs/lib/libbg-sysdeps.so.1 /usr/lib/
This should solve the issue
2. Some time the Qmail-1 is not able to deliver mails to Qmail-2 instance due to /var/tmp/qmail-qfilter directory is not there or vanishes. So a script to check and create the directory with cron is created for taking care of this issue.
The script is /usr/bin/check_qmail-qfilter_dir.sh
#!/bin/sh DIRECTORY=/var/tmp/qmail-qfilter if [ ! -d "$DIRECTORY" ]; then mkdir -p $DIRECTORY; chmod 777 $DIRECTORY; chown -R root.qmail $Directory fi
The cron entry is as follows
*/5 * * * * /usr/bin/check_qmail-qfilter_dir.sh