Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
add disclaimer or tag line to outgoing e-mail
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
apokalyptik
n00b
n00b


Joined: 18 Jun 2002
Posts: 62

PostPosted: Wed Mar 10, 2004 9:30 pm    Post subject: add disclaimer or tag line to outgoing e-mail Reply with quote

--- Adding the following in for better search results ---
email e-mail vpopmail qmail qmailqueue qfilter perl disclaimer tagline tag line add adding outgoing message mesages smtp altermime domain specific
--- Added the preceeding in for better search results ---

This took me a while to figure out... Thought I would share it

edit 03.10.2004 - updated qmail-disclaimer script... error correction with altermime and non-mime e-mail, and lc() is run on the QMAILHOST variable, so all filenames should be in lowercase only format (so Example.com and example.com both pull from the same disclaimer file)

note: 03.10.2004 -- yes I know most people dont like this idea... oh well... I was paid to develop it, and I've passed it along... dont like it? dont do it :) -- cheers.

Step 1: Install qmail-qfilter (masked as of 03.10.2004)
Code:
cd /usr/portage/net-mail/qmail-qfilter

Code:
ls -lah
total 24K
drwxr-xr-x    3 root     root         4.0K Mar 10 07:49 .
drwxr-xr-x  139 root     root         4.0K Mar  9 08:10 ..
-rw-r--r--    1 root     root          467 Aug  7  2003 ChangeLog
-rw-r--r--    1 root     root          189 Aug  7  2003 Manifest
drwxr-xr-x    2 root     root         4.0K Jul 31  2003 files
-rw-r--r--    1 root     root         1022 Jul 31  2003 qmail-qfilter-1.5.ebuild

Code:
emerge ./qmail-qfilter-1.5.ebuild


Step 2: install altermime
Code:
emerge altermime


Step 3: Setup qmail-disclaimer
Code:
nano -w /var/qmail/bin/qmail-disclaimer

Code:
#!/usr/bin/perl -w
use Digest::MD5 qw(md5_hex);
$TEMP_DIR='/tmp/disclaimer/';
$DISCLAIMER_DIR='/var/conf/domains/disclaimers/';
$DISCLAIMER_SUF='.disclaimer.txt';
$ALTERMIME="/usr/bin/altermime";
while ( $input = <> ) {
        $CONTENTS.=$input;
}

$DISCLAIMER=$DISCLAIMER_DIR.lc($ENV{"QMAILHOST"}).$DISCLAIMER_SUF;

if ( -e $DISCLAIMER ) {
        open (FILE, $DISCLAIMER);
                while ( $input = <FILE> ) {
                $DISCMSG.=$input;
        }
        $MD5=md5_hex($CONTENTS);
        $TEMP_FILE=$TEMP_DIR.$MD5;
        open (OUTPUT, ">$TEMP_FILE");
        print OUTPUT $CONTENTS;
        close OUTPUT;
        if ( -e $ALTERMIME ) {
                $SYSCALL="$ALTERMIME --input=$TEMP_FILE --disclaimer=$DISCLAIMER --disclaimer-html=$DISCLAIMER --htmltoo";
                system($SYSCALL);
        }
        open (FILE, $TEMP_FILE);
        while ( $input = <FILE> ) {
                $NEWCONTENTS.=$input;
        }
        close FILE;
        $TSTSBSTR=index $NEWCONTENTS,$DISCMSG;
        if ( $NEWCONTENTS && $TSTSBSTR >= 0 ) {
                print $NEWCONTENTS;
        } else {
                print $CONTENTS."\n\n".$DISCMSG;
        }
        unlink $TEMP_FILE;
} else {
        print $CONTENTS;
}

Code:
chmod a+rx /var/qmail/bin/qmail-disclaimer

Code:
mkdir /tmp/disclaimer/
mkdir /var/conf
mkdir /var/conf/domains
mkdir /var/conf/domains/disclaimers


Step 4: Setup qmail-qfilter-wrapper.sh
Code:
nano -w /var/qmail/bin/qmail-qfilter-wrapper.sh

Code:
#!/bin/bash
exec /var/qmail/bin/qmail-qfilter \
     /var/qmail/bin/qmail-disclaimer

Code:
chmod a+rx /var/qmail/bin/qmail-qfilter-wrapper.sh


Step 5: FORCE the qmailqueue to use this for all connections
Code:
nano -w /service/qmail-smtpd/run

Code:
......
QMAILQUEUE="/var/qmail/bin/qmail-qfilter-wrapper.sh" export QMAILQUEUE

# Now run it all
exec /usr/bin/softlimit ${SOFTLIMIT_OPTS} \
......


Step 6: add a /var/conf/domains/disclaimers/{DOMAIN}.disclaimer.txt file containing the contents of your disclaimer *FOR EACH DOMAIN YOU WISH TO DO THIS TO*
_________________
http://www.apokalyptik.com/


Last edited by apokalyptik on Thu Mar 11, 2004 1:11 am; edited 1 time in total
Back to top
View user's profile Send private message
apokalyptik
n00b
n00b


Joined: 18 Jun 2002
Posts: 62

PostPosted: Wed Mar 10, 2004 9:30 pm    Post subject: Reply with quote

Q: cant i put the disclaimer files in /var/vpopmail/domain/*
A: no, qmail-smtpd does not have perms to read that dir. you would first have to chmod o+r that dir, then reconfigure the script to look at something like this:
Code:
$DISCLAIMER_DIR='/var/vpopmail/domains/';
$DISCLAIMER_SUF='/.disclaimer.txt';

which should cause $DISCLAIMER to be /var/vpopmail/domains/{DOMAIN}/.disclaimer.txt


this, needless to say, isnt recommended
_________________
http://www.apokalyptik.com/
Back to top
View user's profile Send private message
berus
Guru
Guru


Joined: 28 Dec 2003
Posts: 347
Location: Italy

PostPosted: Mon Oct 25, 2004 9:56 am    Post subject: Reply with quote

Hi!
I want to try your script but the disclaimer messages don't appear in sent mail. I modify the script in this way
Code:
$DISCLAIMER_DIR='/var/qmail/control/disclaimers/';
$DISCLAIMER_SUF='.disclaimer.txt';

I create a folder disclaimer with my.domain.disclaimer.txt file. For test I chmod 777 discalimers folders and file.

There is a log to understand how it works?
Thanks

edit: it's a problem if in /etc/tcp.smtp there is this line?
Code:
192.9.200.:allow,RELAYCLIENT="",RBLSMTPD="",QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"
Back to top
View user's profile Send private message
berus
Guru
Guru


Joined: 28 Dec 2003
Posts: 347
Location: Italy

PostPosted: Mon Oct 25, 2004 10:15 am    Post subject: Reply with quote

I change the line in tcp.smtp (for test only, because I want qmail-scanner and clamav queue.. how? :) ) end in qmail-smtp log I read
Quote:
2004-10-25 12:04:11.627086500 print() on closed filehandle OUTPUT at /var/qmail/bin/qmail-disclaimer line 21, <FILE> line 3.
2004-10-25 12:04:11.630423500 readline() on closed filehandle FILE at /var/qmail/bin/qmail-disclaimer line 28, <FILE> line 3.
2004-10-25 12:04:11.630552500 Use of uninitialized value in index at /var/qmail/bin/qmail-disclaimer line 32.
Back to top
View user's profile Send private message
berus
Guru
Guru


Joined: 28 Dec 2003
Posts: 347
Location: Italy

PostPosted: Mon Oct 25, 2004 10:24 am    Post subject: Reply with quote

Ok, I make a wrong tmp dir.. now works!
But to use qmail-scanner-queue.pl and your script together?
Thanks
Back to top
View user's profile Send private message
arunlove007
n00b
n00b


Joined: 07 Jun 2008
Posts: 1

PostPosted: Mon Jun 09, 2008 7:33 am    Post subject: adding disclaimer Reply with quote

I have followed that link and procedure for adding footer to outgoing mails..but it doesn,t work at all.. :( tried with changing script..and /service/qmail-smtpd/run and /home/vpopmail/etc/tcp.smtp looks like this --

#!/bin/sh
export MFDNSCHECK=""
QMAILQUEUE="/var/qmail/bin/simscan" export QMAILQUEUE
QMAILDUID=`id -u vpopmail`
NOFILESGID=`id -g vpopmail`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
exec /usr/local/bin/softlimit -m 30000000 \
/usr/local/bin/tcpserver -H -R -l 0 \
-x /home/vpopmail/etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \
/var/qmail/bin/qmail-smtpd mydomain.com \
/home/vpopmail/bin/vchkpw /bin/true 2>&1

and tcp.smtp
127.:allow,RELAYCLIENT="",QMAILQUEUE="/var/qmail/bin/qmail-tail"
10.10..:allow,RELAYCLIENT="",RBLSMTPD="",QMAILQUEUE="/var/qmail/bin/qmail-tail"
127.:allow,RELAYCLIENT="",QMAILQUEUE="/var/qmail/bin/simscan"
10.:allow,@special-relay="",QMAILQUEUE="/var/qmail/bin/simscan"
:allow,QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"



I have created qmail-tail script as for disclaimer...
#!/bin/bash
exec /var/qmail/bin/qmail-qfilter
/var/qmail/bin/qmail-disclaimer


I do not understand where iam going wrong is there any change need to be done at qmail scanner side...please help ..i need to setup this...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum