2
I Use This!
Activity Not Available

News

Analyzed 4 months ago. based on code collected 11 months ago.
Posted almost 13 years ago by [email protected] (Cprogrammer)
Installing IndiMail from RPM 1. Install OS SUSE o openSUSE 13.2 o openSUSE 13.1 o openSUSE 11.4 o openSUSE Tumbleweed o SUSE Linux Enterprise 12 o SUSE Linux Enterprise 11 SP4 o SUSE Linux Enterprise 11 SP3 o SUSE Linux Enterprise 11 SP2 o SUSE Linux ... [More] Enterprise 11 SP1 o SUSE Linux Enterprise 11 o SUSE Linux Enterprise 10 o openSUSE Factory * Red Hato Feodra 23o Fedora 22 o Fedora 21 o Fedora 20 o Red Hat Enterprise Linux 7 o Red Hat Enterprise Linux 5 o Red Hat Enterprise Linux 6 o CentOS 7 o CentOS 6 o CentOS 5 * Debian o Debian 8.0 o Debian 7.0 o Debian 6.0o Ubuntu 15.10o Ubuntu 15.04 o Ubuntu 14.10 o Ubuntu 14.04 o Ubuntu 13.10 o Ubuntu 13.04 o Ubuntu 12.10 o Ubuntu 12.04 2. Determine if your OS is 32 bit or 64 Bit % uname -m The command will output i386, i586, i686 for 32 bit and x86_64 for 64 bit 3. Download the Repo correspoding to your OS from* http://sourceforge.net/projects/indimail/files/Repo/ e.g Indimail-CentOS7.repo for CentOS 7 and copy that to /etc/yum.repos.d % sudo cp IndiMail-CentOS_7.repo /etc/yum.repos.d/indimail.repo* for Debian Packages, you need to download the corresponding debian package for your OS fromhttp://download.opensuse.org/repositories/home:/indimail 4. Execute the YUM command as per the output of uname command in step 2 % sudo yum install indimail.i386 (for 32 bit)% sudo yum install indimail.x86_64 (for 64 bit)* for debian packages, execute the command% dpkg -i indimail_version_i386.deb (for 32 bit)% dpkg -i indimail_version_amd64.deb (for 64 bit) The above should install IndiMail 5. Shutdown MySQL if already running and disable MySQL being started up by the system % /etc/init.d/mysqld stop % sudo chkconfig mysqld off % /bin/rm -f /service/mysql.3306/down 6. Start IndiMail % sudo service indimail start 7. Check if everthing is fine by running the svstat command % sudo /var/indimail/bin/svstat /service/*/service/clamd: up (pid 1579) 1028 seconds /service/fetchmail: up (pid 1578) 1028 seconds /service/freshclam: up (pid 1584) 1028 seconds /service/greylist.1999: up (pid 1581) 1028 seconds /service/indisrvr.4000: up (pid 1570) 1028 seconds /service/inlookup.infifo: up (pid 1568) 1028 seconds /service/mysql.3306: up (pid 1555) 1029 seconds /service/proxy-imapd.4143: up (pid 1549) 1029 seconds /service/proxy-imapd-ssl.9143: up (pid 1548) 1029 seconds /service/proxy-pop3d.4110: up (pid 1554) 1029 seconds /service/proxy-pop3d-ssl.9110: up (pid 1583) 1028 seconds /service/pwdlookup: up (pid 1580) 1028 seconds /service/qmail-imapd.143: up (pid 1576) 1028 seconds /service/qmail-imapd-ssl.993: up (pid 1594) 1028 seconds /service/qmail-pop3d.110: up (pid 1597) 1028 seconds /service/qmail-pop3d-ssl.995: up (pid 1577) 1028 seconds /service/qmail-poppass.106: up (pid 1587) 1028 seconds /service/qmail-qmqpd.628: down 1029 seconds /service/qmail-qmtpd.209: up (pid 1564) 1029 seconds /service/qmail-send.25: up (pid 1553) 1029 seconds /service/qmail-smtpd.25: up (pid 1598) 1028 seconds /service/qmail-smtpd.366: up (pid 1565) 1029 seconds /service/qmail-smtpd.465: up (pid 1551) 1029 seconds /service/qmail-smtpd.587: up (pid 1559) 1029 seconds /service/qmail-spamlog: up (pid 1552) 1029 seconds /service/qscanq: up (pid 3802) 29 seconds8. Play with the system Add a domain % sudo /var/indimail/bin/vadddomain example.com password Add a user % sudo /var/indimail/bin/vadduser [email protected] password Send an email using SMTP % swaks --to youremail@yourdomain --from [email protected] --server localhost Inject a mail locally % cat /tmp/email.msg | mail -s "testing indimail" [email protected] you@yourdomain 9. Set up your .bash_profile and RTFM PATH=$PATH:/var/indimail/bin:/var/indimail/sbin MANPATH=$MANPATH:/var/indimail/man % man indimail 10. Buy beer for Manvendra Bhangui NOTE: The MySQL database gets installed with the user 'mysql' with all privileges and a user 'indimail' with limited privileges. You will find the passwords for these two users in the script /var/indimail/sbin/svctool. If you modify these, please don't forget to modify /var/indimail/control/host.mysql [Less]
Posted almost 13 years ago by [email protected] (Cprogrammer)
Often you will find program like MS outlook, notorious for sending duplicate emails, flooding your inbox. IndiMail allows you to quickly deal with this proprietary nonsense by turning on duplicate eliminator in vdelivermail(8) - the default MDA. To ... [More] turn on the duplicate eliminator in vdelivermail, you need to set ELIMINATE_DUPS and MAKE_SEEKABLE environment variables.% su# echo 1> /service/qmail-send.25/variables/ELIMINATE_DUPS# echo 1> /service/qmail-send.25/variables/MAKE_SEEKABLE# svc -d /service/qmail-send.25; svc -u /service/qmail-send.25# exitIf you do not use vdelivermail and want to use your own delivery agent? Fear not by using ismaildup(1). ismaildup expects the email on standard input and is easily scriptable like the example below in a .qmail file.   | ismaildup /var/indimail/bin/maildirdeliver /home/manny/Maildirwill deliver mails to /home/manny/Maildir while discarding duplicates.If you are not happy with the 900 seconds (15 minutes) time interval for checking duplicates, you can change it by setting the DUPLICATE_INTERVAL environment variable. The following will not allow a single duplicate to be entertained within 24 hours% su# echo 86400 > /service/qmail-send.25/variables/DUPLICATE_INTERVAL# svc -d /service/qmail-send.25 ; svc -u /service/qmail-send.25# exit [Less]
Posted almost 13 years ago by [email protected] (Manvendra Bhangui)
Often you will find program like MS outlook, notorious for sending duplicate emails, flooding your inbox. IndiMail allows you to quickly deal with this proprietary nonsense by turning on duplicate eliminator in vdelivermail(8) - the default MDA. To ... [More] turn on the duplicate eliminator in vdelivermail, you need to set ELIMINATE_DUPS and MAKE_SEEKABLE environment variables.% su# echo 1> /service/qmail-send.25/variables/ELIMINATE_DUPS# echo 1> /service/qmail-send.25/variables/MAKE_SEEKABLE# svc -d /service/qmail-send.25; svc -u /service/qmail-send.25# exitIf you do not use vdelivermail and want to use your own delivery agent? Fear not by using ismaildup(1). ismaildup expects the email on standard input and is easily scriptable like the example below in a .qmail file.   | ismaildup /var/indimail/bin/maildirdeliver /home/manny/Maildirwill deliver mails to /home/manny/Maildir while discarding duplicates.If you are not happy with the 900 seconds (15 minutes) time interval for checking duplicates, you can change it by setting the DUPLICATE_INTERVAL environment variable. The following will not allow a single duplicate to be entertained within 24 hours% su# echo 86400 > /service/qmail-send.25/variables/DUPLICATE_INTERVAL# svc -d /service/qmail-send.25 ; svc -u /service/qmail-send.25# exit [Less]
Posted almost 13 years ago by [email protected] (Cprogrammer)
Often you will find program like MS outlook, notorious for sending duplicate emails, flooding your inbox. IndiMail allows you to quickly deal with this proprietary nonsense by turning on duplicate eliminator in vdelivermail(8) - the default MDA. To ... [More] turn on the duplicate eliminator in vdelivermail, you need to set ELIMINATE_DUPS and MAKE_SEEKABLE environment variables. % su # echo 1> /service/qmail-send.25/variables/ELIMINATE_DUPS # echo 1> /service/qmail-send.25/variables/MAKE_SEEKABLE # svc -d /service/qmail-send.25; svc -u /service/qmail-send.25 # exit If you do not use vdelivermail and want to use your own delivery agent? Fear not by using ismaildup(1). The ismaildup expects the email on standard input and is easily scriptable like the example below in a .qmail file.    | ismaildup /var/indimail/bin/maildirdeliver /home/manny/Maildir will deliver mails to /home/manny/Maildir while discarding duplicates. If you are not happy with the 900 seconds (15 minutes) time interval for checking duplicates, you can change it by setting the DUPLICATE_INTERVAL environment variable. The following will not allow a single duplicate to be entertained within 24 hours % su # echo 86400 > /service/qmail-send.25/variables/DUPLICATE_INTERVAL # svc -d /service/qmail-send.25 ; svc -u /service/qmail-send.25 # exit [Less]
Posted almost 13 years ago by [email protected] (Cprogrammer)
IndiMail follows the traditional UNIX philosophy."Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface"This allows IndiMail to interface with ... [More] many programs written by others. IndiMail uses a powerful filter mechanism called vfilter(8). You may already be familiar with procmail. procmail is a mail delivery agent (MDA) capable of sorting incoming mail into various directories and filtering out messages. There are three ways in which you can use procmail with IndiMail.1. inside .qmailUsers can use| preline procmailfrom ~/.qmail. They will need to use a full path for procmail unless procmail is in the system's startup PATH.2. Edit .qmail-default| preline -f procmail -p -m /var/indimail/etc/procmailrc3. Have an aliasYou can use valias(1) to create an alias to call procmail. The following alias calls procmail to deliver the mail using /var/indimail/etc/procmailrc as a procmail recipevalias -i "|/var/indimail/bin/preline -f /usr/bin/procmail -p -m /var/indimail/etc/procmailrc" [email protected] following procmailrc puts virus infected mails in /tmp/Maildir and calls maildirdeliver(1) to deliver the mail to /home/mail/T2Zsym/example.com/testuser01/Maildir.SHELL=/bin/bashVERBOSE="no"unset DTLINEunset RPLINE:0w*^X-Virus-Status: INFECTED/tmp/Maildir/.Virus:0w| /var/indimail/bin/maildirdeliver /home/mail/T2Zsym/example.com/testuser01/MaildirYou can replace maildirdeliver in the last line with vdelivermail(8)| /var/indimail/bin/vdelivermail '' bounce-no-mailbox [Less]
Posted almost 13 years ago by [email protected] (Cprogrammer)
IndiMail follows the traditional UNIX philosophy. "Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface" This allows IndiMail to interface ... [More] with many programs written by others. IndiMail uses a powerful filter mechanism called vfilter(8). You may already be familiar with procmail. procmail is a mail delivery agent (MDA) capable of sorting incoming mail into various directories and filtering out messages. There are three ways in which you can use procmail with IndiMail. 1. inside .qmail Users can use | preline procmail from ~/.qmail. They will need to use a full path for procmail unless procmail is in the system's startup PATH. 2. Edit .qmail-default            | preline -f procmail -p -m /var/indimail/etc/procmailrc 3. Have an alias You can use valias(1) to create an alias to call procmail. The following alias calls procmail to deliver the mail using /var/indimail/etc/procmailrc as a procmail recipe     valias -i "|/var/indimail/bin/preline -f /usr/bin/procmail -p -m /var/indimail/etc/procmailrc" [email protected] The following procmailrc puts virus infected mails in /tmp/Maildir and calls maildirdeliver(1) to deliver the mail to /home/mail/T2Zsym/example.com/testuser01/Maildir. SHELL=/bin/bashVERBOSE="no"unset DTLINEunset RPLINE:0w*^X-Virus-Status: INFECTED/tmp/Maildir/.Virus:0w| /var/indimail/bin/maildirdeliver /home/mail/T2Zsym/example.com/testuser01/Maildir You can replace maildirdeliver in the last line with vdelivermail(8) | /var/indimail/bin/vdelivermail '' bounce-no-mailbox [Less]
Posted almost 13 years ago by [email protected] (Manvendra Bhangui)
IndiMail follows the traditional UNIX philosophy."Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface"This allows IndiMail to interface with ... [More] many programs written by others. IndiMail uses a powerful filter mechanism called vfilter(8). You may already be familiar with procmail. procmail is a mail delivery agent (MDA) capable of sorting incoming mail into various directories and filtering out messages. There are three ways in which you can use procmail with IndiMail.1. inside .qmail Users can use| preline procmailfrom ~/.qmail. They will need to use a full path for procmail unless procmail is in the system's startup PATH.2. Edit .qmail-default | preline -f procmail -p -m /var/indimail/etc/procmailrc3. Have an alias You can use valias(1) to create an alias to call procmail. The following alias calls procmail to deliver the mail using /var/indimail/etc/procmailrc as a procmail recipevalias -i "|/var/indimail/bin/preline -f /usr/bin/procmail -p -m /var/indimail/etc/procmailrc" [email protected] following procmailrc puts virus infected mails in /tmp/Maildir and calls maildirdeliver(1) to deliver the mail to /home/mail/T2Zsym/example.com/testuser01/Maildir.SHELL=/bin/bashVERBOSE="no"unset DTLINEunset RPLINE:0w*^X-Virus-Status: INFECTED/tmp/Maildir/.Virus:0w| /var/indimail/bin/maildirdeliver /home/mail/T2Zsym/example.com/testuser01/MaildirYou can replace maildirdeliver in the last line with vdelivermail(8)| /var/indimail/bin/vdelivermail '' bounce-no-mailbox [Less]
Posted almost 13 years ago by [email protected] (Manvendra Bhangui)
IndiMail follows the traditional UNIX philosophy."Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface"This allows IndiMail to interface with ... [More] many programs written by others. IndiMail uses a powerful filter mechanism called vfilter(8). You may already be familiar with procmail. procmail is a mail delivery agent (MDA) capable of sorting incoming mail into various directories and filtering out messages. There are three ways in which you can use procmail with IndiMail.1. inside .qmail Users can use| preline procmailfrom ~/.qmail. They will need to use a full path for procmail unless procmail is in the system's startup PATH.2. Edit .qmail-default | preline -f procmail -p -m /var/indimail/etc/procmailrc3. Have an alias You can use valias(1) to create an alias to call procmail. The following alias calls procmail to deliver the mail using /var/indimail/etc/procmailrc as a procmail recipevalias -i "|/var/indimail/bin/preline -f /usr/bin/procmail -p -m /var/indimail/etc/procmailrc" [email protected] following procmailrc puts virus infected mails in /tmp/Maildir and calls maildirdeliver(1) to deliver the mail to /home/mail/T2Zsym/example.com/testuser01/Maildir.SHELL=/bin/bashVERBOSE="no"unset DTLINEunset RPLINE:0w*^X-Virus-Status: INFECTED/tmp/Maildir/.Virus:0w| /var/indimail/bin/maildirdeliver /home/mail/T2Zsym/example.com/testuser01/MaildirYou can replace maildirdeliver in the last line with vdelivermail(8)| /var/indimail/bin/vdelivermail '' bounce-no-mailbox [Less]
Posted almost 13 years ago by [email protected] (Cprogrammer)
IndiMail provides multiple methods by which you can intercept an email in transit and modify the email headers or the email body. A filter is a simple program that expects the raw email on standard input and outputs the message text back on standard ... [More] output. The program /bin/cat can be used as a filter which simply copies the standard input to standard output without modifying anything. Some methods can be used before the mail gets queued and some methods can be used before the execution of local / remote delivery. Let us say that we have written a script /usr/local/bin/myfilter. The myfilter program expects the raw email on stdin and outputs the email back (maybe modiying it) on stdout. We will discuss how to write our sample myfilter program in section 1.4 1.1 Filtering during SMTP (before mail gets queued)1.1.1 Using FILTERARGS environment variableThe below configuration causes all inbound SMTP email to be fed through the filter /usr/local/bin/myfilter. You can use the programs 822header(1), 822body(1) inside myfilter to get and manipulate the headers and body. % su root# echo /usr/local/bin/myfilter > /service/qmail-smtpd.25/variables/FILTERARGS# svc -d /service/qmail-smtpd.25# svc -u /service/qmail-smtpd.25 NOTE: If the program myfilter returns 100, the message will be bounced. If it returns 2, the message will be discarded (blackholed). 1.1.2 Using QMAILQUEUE with qmail-qfilter You can use qmail-qfilter(1). qmail-qfilter allows you to run multiple filters passed as command line arguments to qmail-qfilter. Since QMAILQUEUE doesn't allow you to specify multiple arguments, you can write a shell script which calls qmail-qfilter and have the shell script defined as QMAILQUEUE environment variable. % su root# echo /var/indimail/bin/qmail-qfilter /usr/local/bin/myfilter > /usr/local/bin/qfilter # chmod x /usr/local/bin/qfilter # echo /usr/local/bin/qfilter > /service/qmail-smtpd.25/variables/QMAILQUEUE# echo /var/indimail/bin/qmail-dk > /service/qmail-smtpd.25/variabels/QQF_QMAILQUEUE# svc -d /service/qmail-smtpd.25# svc -u /service/qmail-smtpd.25 1.1.3 Using QMAILQUEUE with your own program When you want to use your own program as QMAILQUEUE, then your program is responsible for queuing the email. It is trivial to queue the email by calling qmail-multi(8). You script can read the stdin for the raw message (headers body) and pipe the output (maybe after modifications) to qmail-multi(8). If you are doing DK/DKIM signing, you can execute qmail-dk(8) instead of qmail-multi(8). You can have qmail-dk(8) call qmail-dkim(8) and qmail-dkim(8) calls qmail-multi(8). Assuming you want to do DK/DKIM signing, and myfilter calls qmail-dk(8), you can do the following % su root # echo /usr/local/bin/myfilter > /service/qmail-smtpd.25/variables/QMAILQUEUE# echo /var/indimail/bin/qmail-dkim > /service/qmail-smtpd.25/variables/DKQUEUE# echo /var/indimail/bin/qmail-multi > /service/qmail-smtpd.25/variables/DKIMQUEUE# svc -d /service/qmail-smtpd.25# svc -u /service/qmail-smtpd.25 NOTE: You can set the environment variable NULLQUEUE before calling qmail-multi to discard the mail completely (blackhole). 1.2 Filtering during local / remote delivery 1.2.1 Using FILTERARGS environment variable The below configuration causes all local / remote deliveries to be fed through the filter /usr/local/bin/myfilter. You can use the programs 822header(1), 822body(1) inside myfilter to get and manipulate the headers and body. % su root# echo /usr/local/bin/myfilter > /service/qmail-send.25/variables/FILTERARGS# svc -d /service/qmail-send.25# svc -u /service/qmail-send.25 If you want to filter only for local delivery or only for remote delivery, you can use the environment variable QMAILLOCAL or QMAILREMOTE. QMAILLOCAL is defined only for local deliveries while QMAILREMOTE is defined only for remote deliveries. NOTE: If the program myfilter returns 100, the message will be bounced. If it returns 2, the message will be discarded (blackholed). e.g. the below script skips filtering for remote deliveries #!/bin/shif [ -n "$QMAILREMOTE" ] ; then    exec /bin/catfi# rest of the script......exit 0 1.2.2 Using control file filterargsThe control file filterargs gives you control to run filters individually for local or remote deliveries. It also allows you to run your filter for both local and remote deliveries. See spawn-filter(8) for full description on this control fileIndiMail e.g. The following entry in /var/indimail/control/filterargs causes all mails to yahoo.com be fed through the filter dk-filter(8) for DK/DKIM signing. yahoo.com:remote:/var/indimail/bin/dk-filter NOTE: If the program myfilter returns 100, the message will be bounced. If it returns 2, the message will be discarded (blackholed). 1.2.3 Using QMAILLOCAL or QMAILREMOTE environment variables If you define QMAILLOCAL, indimail will execute the program/script defined by the QMAILLOCAL variable for all local deliveries. The arguments passed to this program/script will be the same as that for qmail-local(8). Similarly, if you define QMAILREMOTE, indimail will execute the program/script defined by the QMAILREMOTE variable for all remote deliveries. The argument passed to this program/script are the same as that for qmail-remote(8). The raw email (header body) is available on stdin. You can use 822header(8), 822body(8) for getting the headers and body. After your program is through with filtering, the output should be piped to qmail-local(8) for local deliveries and qmail-remote(8) for remote deliveries. You need to also call qmail-local / qmail-remote with the same arguments. i.e exec qmail-local "$@"        #(for local deliveries) exec qmail-remote "$@"     #(for remote deliveries) NOTE: You can exit with value 0 instead of calling qmail-local / qmail-remote to discard the mail completely (blackhole) 1.3 Using dot-qmail(5) or valias(1) Both .qmail files and valias mechanism allows you to execute your own programs for local deliveries. See the man pages for dot-qmail(5) and valias(1) for more details. After manipulating the original raw email on stdin, you can pipe the out to the program maildirdeliver(1) for the final delivery. Assuming you write the program myfilter to call maildirdeliver program, you can use the valias command to add the following alias % valias -i "|/usr/local/bin/myfilter" [email protected] Now any mail sent to [email protected] will be given to the program /usr/local/bin/myfilter as standard input. NOTE: you can exit with value 0 instead of calling the maildirdeliver program to discard the mail completely (blackhole). 1.4 Using IndiMail rule based filter - vfilter IndiMail's vfilter(8) mechanism allows you to create rule based filter based on any keyword in the message headers or message body. You can create a vfilter by calling the vcfilter(1) program. % vcfilter -i -t myfilter -h 2 -c 0 -k "failure notice" -f /NoDeliver \     -b "2|/usr/local/bin/myfilter" [email protected] NOTE: you can exit with value 0 instead of putting anything on standard output       to discard the mail completely (blackhole). 1.5 Examples Example the below filter looks for emails having "failure notice" in the subject line and inserts the line "sorry about that" in the first line of the message body and puts the line “sent by IndiMail Messaging platform” in the last line 1.5.1 FILTERARGS Script A FILTERARGS script can be used during SMTP before the mail gets queued and also after the mail gets picked up from the queue but just before local / remote delivery #/bin/sh# create a temporary file tmp_file=`mktemp -p /var/tmp -t myfilter.XXXXXXXXXXXXXXX` # Copy the stdin /bin/cat > $tmp_file subject=`/var/indimail/bin/822header -I Subject < $tmp_file` echo $subject | grep "failure notice" > /dev/null 2>&1 if [ $? -eq 0 ] ; then ( /var/indimail/bin/822header < $tmp_file echo echo "sorry about that" /var/indimail/bin/822body < $tmp_file echo "sent by IndiMail Messaging platform" ) else /bin/cat $tmp_file fi /bin/rm -f $tmp_file exit 0 1.5.2 QMAILQUEUE script #!/bin/sh # create a temporary file inp_file=`mktemp -p /var/tmp -t myfilteri.XXXXXXXXXXXXXXX`out_file=`mktemp -p /var/tmp -t myfiltero.XXXXXXXXXXXXXXX` if [ $? -ne 0 ] ; then /bin/rm -f $inp_file exit 111 fi /bin/cat > $inp_file if [ $? -ne 0 ] ; then /bin/rm -f $inp_file exit 111 fi subject=`/var/indimail/bin/822header -I Subject < $inp_file` echo $subject | grep "failure notice" > /dev/null 2>&1 if [ $? -eq 0 ] ; then ( /var/indimail/bin/822header < $inp_file echo echo "sorry about that" /var/indimail/bin/822body < $inp_file echo "sent by IndiMail Messaging platform" ) > $out_file if [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111 fi exec 0<$out_file /bin/rm -f $inp_file $out_file else exec 0<$inp_file /bin/rm -f $inp_file fi # queue the message exec /var/indimail/bin/qmail-multi exit 111 1.5.3 QMAILREMOTE script #!/bin/sh if [ -n "$PWSTRUCT" ] ; then exec -a qmail-local /var/indimail/bin/spawn-filter "$@" fi# create a temporary fileinp_file=`mktemp -p /var/tmp -t myfilteri.XXXXXXXXXXXXXXX`out_file=`mktemp -p /var/tmp -t myfiltero.XXXXXXXXXXXXXXX` /bin/cat > $inp_file subject=`/var/indimail/bin/822header -I Subject < $inp_file` echo $subject | grep "failure notice" > /dev/null 2>&1 if [ $? -eq 0 ] ; then ( /var/indimail/bin/822header < $inp_file echo echo "sorry about that" /var/indimail/bin/822body < $inp_file echo "sent by IndiMail Messaging platform" ) > $out_file exec 0<$out_file /bin/rm -f $inp_file $out_file else exec 0<$inp_file /bin/rm -f $inp_file fi exec -a qmail-remote /var/indimail/bin/spawn-filter "$@" exit 111 1.5.4 QMAILLOCAL script #!/bin/sh # create a temporary file if [ -z "$PWSTRUCT" ] ; then exec -a qmail-remote /var/indimail/bin/spawn-filter "$@" fi inp_file=`mktemp -p /var/tmp -t myfilteri.XXXXXXXXXXXXXXX`out_file=`mktemp -p /var/tmp -t myfiltero.XXXXXXXXXXXXXXX` /bin/cat > $inp_file subject=`/var/indimail/bin/822header -I Subject < $inp_file` echo $subject | grep "failure notice" > /dev/null 2>&1 if [ $? -eq 0 ] ; then ( /var/indimail/bin/822header < $inp_file echo echo "sorry about that" /var/indimail/bin/822body < $inp_file echo "sent by IndiMail Messaging platform" ) > $out_file exec 0<$out_file /bin/rm -f $inp_file $out_file else exec 0<$inp_file /bin/rm -f $inp_file fi exec -a qmail-local /var/indimail/bin/spawn-filter "$@" exit 111 1.5.5 valias/vfilter script #!/bin/sh # create a temporary file inp_file=`mktemp -p /var/tmp -t myfilteri.XXXXXXXXXXXXXXX` if [ $? -ne 0 ] ; then /bin/rm -f $inp_file exit 111 fi out_file=`mktemp -p /var/tmp -t myfiltero.XXXXXXXXXXXXXXX` if [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111 fi /bin/cat > $inp_file if [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111 fi subject=`/var/indimail/bin/822header -I Subject < $inp_file` echo $subject | grep "failure notice" > /dev/null 2>&1 if [ $? -eq 0 ] ; then ( /var/indimail/bin/822header < $inp_file echo echo "sorry about that" /var/indimail/bin/822body < $inp_file echo "sent by IndiMail Messaging platform" ) > $out_file if [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111 fi exec 0<$out_file else exec 0<$inp_file fi /bin/rm -f $inp_file $out_file## unset RPLINE so that maildirdeliver does not add a duplicate Return-Path line#unset RPLINE dir=`/var/indimail/bin/vuserinfo -d [email protected] | cut -d: -f2 |cut -c2-`if [ $? -ne 0 ] ; then echo "unable to get user's homedir" 1>&2 exit 111fi exec /var/indimail/bin/maildirdeliver "$dir"/Maildir exit 111 [Less]
Posted almost 13 years ago by [email protected] (Manvendra Bhangui)
IndiMail provides multiple methods by which you can intercept an email in transit and modify the email headers or the email body. A filter is a simple program that expects the raw email on standard input and outputs the message text back on standard ... [More] output. The program /bin/cat can be used as a filter which simply copies the standard input to standard output without modifying anything. Some methods can be used before the mail gets queued and some methods can be used before the execution of local / remote delivery.It is not necessary for a filter to modify the email. You can have a filter just to extract the headers or body and use that information for some purpose. IndiMail also provides the following programs - 822addr(1), 822headerfilter(1), 822bodyfilter(1), 822field(1), 822fields(1), 822header(1), 822body(1), 822headerok(1), 822received(1), 822date(1), 822fields(1) to help in processing emails.Let us say that we have written a script /usr/local/bin/myfilter. The myfilter program expects the raw email on stdin and outputs the email back (maybe modiying it) on stdout. 1.1 Filtering during SMTP (before mail gets queued) 1.1.1 Using FILTERARGS environment variable The below configuration causes all inbound SMTP email to be fed through the filter /usr/local/bin/myfilter. You can use the programs 822header(1), 822body(1) inside myfilter to get and manipulate the headers and body (See 1.5.1). % su root# echo /usr/local/bin/myfilter > /service/qmail-smtpd.25/variables/FILTERARGS# svc -d /service/qmail-smtpd.25# svc -u /service/qmail-smtpd.25 NOTE: If the program myfilter returns 100, the message will be bounced. If it returns 2, the message will be discarded (blackholed). 1.1.2 Using QMAILQUEUE with qmail-qfilter You can use qmail-qfilter(1). qmail-qfilter allows you to run multiple filters passed as command line arguments to qmail-qfilter. Since QMAILQUEUE doesn't allow you to specify multiple arguments, you can write a shell script which calls qmail-qfilter and have the shell script defined as QMAILQUEUE environment variable. % su root# echo /var/indimail/bin/qmail-qfilter /usr/local/bin/myfilter > /usr/local/bin/qfilter# chmod +x /usr/local/bin/qfilter# echo /usr/local/bin/qfilter > /service/qmail-smtpd.25/variables/QMAILQUEUE# echo /var/indimail/bin/qmail-dk > /service/qmail-smtpd.25/variabels/QQF_QMAILQUEUE# svc -d /service/qmail-smtpd.25# svc -u /service/qmail-smtpd.25 NOTE: you can define QQF_MAILQUEUE to /var/indimail/bin/qmail-nullqueue to discard the mail (blackhole). 1.1.3 Using QMAILQUEUE with your own program When you want to use your own program as QMAILQUEUE, then your program is responsible for queuing the email. It is trivial to queue the email by calling qmail-multi(8). You script can read the stdin for the raw message (headers + body) and pipe the output (maybe after modifications) to qmail-multi(8). If you are doing DK/DKIM signing, you can execute qmail-dk(8) instead of qmail-multi(8). You can have qmail-dk(8) call qmail-dkim(8) and qmail-dkim(8) calls qmail-multi(8). Assuming you want to do DK/DKIM signing, and myfilter calls qmail-dk(8), you can do the following % su root# echo /usr/local/bin/myfilter > /service/qmail-smtpd.25/variables/QMAILQUEUE# echo /var/indimail/bin/qmail-dkim > /service/qmail-smtpd.25/variables/DKQUEUE# echo /var/indimail/bin/qmail-multi > /service/qmail-smtpd.25/variables/DKIMQUEUE# svc -d /service/qmail-smtpd.25# svc -u /service/qmail-smtpd.25 NOTE: You can set the environment variable NULLQUEUE before calling qmail-multi to discard the mail completely (blackhole). 1.2 Filtering during local / remote delivery 1.2.1 Using FILTERARGS environment variable The below configuration causes all local / remote deliveries to be fed through the filter /usr/local/bin/myfilter. You can use the programs 822header(1), 822body(1) inside myfilter to get and manipulate the headers and body. % su root# echo /usr/local/bin/myfilter > /service/qmail-send.25/variables/FILTERARGS# svc -d /service/qmail-send.25# svc -u /service/qmail-send.25 If you want to filter only for local delivery or only for remote delivery, you can use the environment variable QMAILLOCAL or QMAILREMOTE. QMAILLOCAL is defined only for local deliveries while QMAILREMOTE is defined only for remote deliveries. NOTE: If the program myfilter returns 100, the message will be bounced. If it returns 2, the message will be discarded (blackholed). e.g. the below script skips filtering for remote deliveries #!/bin/shif [ -n “$QMAILREMOTE” ] ; then exec /bin/catfi# rest of the script......exit 0 1.2.2 Using control file filterargs The control file filterargs gives you control to run filters individually for local or remote deliveries. It also allows you to run your filter for both local and remote deliveries. See spawn-filter(8) for full description on this control file e.g. The following entry in /var/indimail/control/filterargs causes all mails to yahoo.com be fed through the filter dk-filter(8) for DK/DKIM signing. yahoo.com:remote:/var/indimail/bin/dk-filter NOTE: If the program myfilter returns 100, the message will be bounced. If it returns 2, the message will be discarded (blackholed). 1.2.3 Using QMAILLOCAL or QMAILREMOTE environment variables If you define QMAILLOCAL, indimail will execute the program/script defined by the QMAILLOCAL variable for all local deliveries. The arguments passed to this program/script will be the same as that for qmail-local(8). Similarly, if you define QMAILREMOTE, indimail will execute the program/script defined by the QMAILREMOTE variable for all remote deliveries. The argument passed to this program/script are the same as that for qmail-remote(8). The raw email (header + body) is available on stdin. You can use 822header(8), 822body(8) for getting the headers and body. After your program is through with filtering, the output should be piped to qmail-local(8) for local deliveries and qmail-remote(8) for remote deliveries. You need to also call qmail-local / qmail-remote with the same arguments. i.e exec qmail-local "$@" #(for local deliveries)exec qmail-remote "$@" #(for remote deliveries) NOTE: You can exit with value 0 instead of calling qmail-local / qmail-remote to discard the mail completely (blackhole) 1.3 Using dot-qmail(5) or valias(1) Both .qmail files and valias mechanism allows you to execute your own programs for local deliveries. See the man pages for dot-qmail(5) and valias(1) for more details. After manipulating the original raw email on stdin, you can pipe the out to the program maildirdeliver(1) for the final delivery. Assuming you write the program myscript to call maildirdeliver program, you can use the valias command to add the following alias % valias -i "|/usr/local/bin/myfilter" [email protected] Now any mail sent to [email protected] will be given to the program /usr/local/bin/myfilter as standard input. NOTE: you can exit with value 0 instead of calling the maildirdeliver program to discard the mail completely (blackhole). 1.4 Using IndiMail rule based filter - vfilter IndiMail's vfilter(8) mechanism allows you to create rule based filter based on any keyword in the message headers or message body. You can create a vfilter by calling the vcfilter(1) program. % vcfilter -i -t myfilter -h 2 -c 0 -k "failure notice" -f /NoDeliver -b "2|/usr/local/bin/myfilter" [email protected] NOTE: you can exit with value 0 instead of putting anything on standard output to discard the mail completely (blackhole). 1.5 Examples Filters e.g. the below filter looks for emails having "failure notice" in the subject line and inserts the line "sorry about that" in the first line of the message body and puts the line “sent by IndiMail Messaging platform” in the last line 1.5.1 FILTERARGS script #bin/sh# create a temporary filetmp_file=`mktemp -p /var/tmp -t myfilter.XXXXXXXXXXXXXXX`if [ $? -ne 0 ] ; then /bin/rm -f $inp_file exit 111fi# Copy the stdin/bin/cat > $tmp_fileif [ $? -ne 0 ] ; then /bin/rm -f $inp_file exit 111fisubject=`/var/indimail/bin/822header -I Subject < $tmp_file`echo $subject | grep "failure notice" > /dev/null 2>&1if [ $? -eq 0 ] ; then ( /var/indimail/bin/822header < $tmp_file echo echo "sorry about that" /var/indimail/bin/822body < $tmp_file echo "sent by IndiMail Messaging platform" )else /bin/cat $tmp_filefi/bin/rm -f $tmp_fileexit 0 1.5.2 QMAILQUEUE script #!/bin/sh# create a temporary fileinp_file=`mktemp -p /var/tmp -t myfilteri.XXXXXXXXXXXXXXX`if [ $? -ne 0 ] ; then /bin/rm -f $inp_file exit 111fiout_file=`mktemp -p /var/tmp -t myfiltero.XXXXXXXXXXXXXXX`if [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111fi/bin/cat > $inp_fileif [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111fisubject=`/var/indimail/bin/822header -I Subject < $inp_file`echo $subject | grep "failure notice" > /dev/null 2>&1if [ $? -eq 0 ] ; then ( /var/indimail/bin/822header < $inp_file echo echo "sorry about that" /var/indimail/bin/822body < $inp_file echo "sent by IndiMail Messaging platform" ) > $out_file if [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111 fi exec 0<$out_fileelse exec 0<$inp_filefi/bin/rm -f $inp_file $out_file# queue the messageexec /var/indimail/bin/qmail-multiexit 111 1.5.3 QMAILREMOTE script #!/bin/sh# This scripts expects qmail-remote arguments on command line# argv0 - qmail-remote# argv1 - host (host)# argv2 - sender (sender)# argv3 - qqeh (qmail queue extra header)# argv4 - size# argv5 .. argvn - recipients# #host=$1sender=$2qqeh=$3size=$4shift 4## if needed you can modify host, sender, qqeh, size args above#if [ -z "$QMAILREMOTE" ] ; then # execute qmail-local # call spawn-filter so that features like # FILTERARGS, SPAMFILTER are not lost exec -a qmail-local /var/indimail/bin/spawn-filter "$@"fiif [ " $CONTROLDIR" = " " ] ; then FN=/var/indimail/control/filterargselse FN=$CONTROLDIR/filterargsfiif [ -n "$SPAMFILTER" -o -n "$FILTERARGS" -o -f $FN ] ; then # execute spawn-filter if you have filters defined for remote/local deliveries PROG="bin/spawn-filter"else PROG="bin/qmail-remote"fi# create a temporary fileinp_file=`mktemp -p /var/tmp -t myfilteri.XXXXXXXXXXXXXXX`if [ $? -ne 0 ] ; then /bin/rm -f $inp_file exit 111fiout_file=`mktemp -p /var/tmp -t myfiltero.XXXXXXXXXXXXXXX`if [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111fi/bin/cat > $inp_fileif [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111fisubject=`/var/indimail/bin/822header -I Subject < $inp_file`echo $subject | grep "failure notice" > /dev/null 2>&1if [ $? -eq 0 ] ; then ( /var/indimail/bin/822header < $inp_file echo echo "sorry about that" /var/indimail/bin/822body < $inp_file echo "sent by IndiMail Messaging platform" ) > $out_file if [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111 fi exec 0<$out_fileelse exec 0<$inp_filefi/bin/rm -f $inp_file $out_file# $PROG points to spawn-filter if FILTERARGS or SPAMFILTER is set# use $PROG so that features like FILTERARGS, SPAMFILTER are not lostexec -a qmail-remote $PROG "$host" "$sender" "$qqeh" $size $*exit 1111.5.4 QMAILLOCAL script #!/bin/sh# This scripts expects qmail-local arguments on command line# argv0 - qmail-local# argv1 - user# argv2 - homedir# argv3 - local# argv4 - dash# argv5 - ext# argv6 - domain# argv7 - sender# argv8 - defaultdelivery (mbox, Maildir)# argv9 - qqeh#user=$1homedir=$2local=$3dash=$4ext=$5domain=$6sender=$7defaultdel=$8qqeh=$9if [ -z "$QMAILLOCAL" ] ; then # execute qmail-remote # call spawn-filter so that features like # FILTERARGS, SPAMFILTER are not lost exec -a qmail-remote /var/indimail/bin/spawn-filter "$@"fi# create a temporary fileinp_file=`mktemp -p /var/tmp -t myfilteri.XXXXXXXXXXXXXXX`if [ $? -ne 0 ] ; then /bin/rm -f $inp_file exit 111fiout_file=`mktemp -p /var/tmp -t myfiltero.XXXXXXXXXXXXXXX`if [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111fi/bin/cat > $inp_fileif [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111fisubject=`/var/indimail/bin/822header -I Subject < $inp_file`echo $subject | grep "failure notice" > /dev/null 2>&1if [ $? -eq 0 ] ; then ( /var/indimail/bin/822header < $inp_file echo echo "sorry about that" /var/indimail/bin/822body < $inp_file echo "sent by IndiMail Messaging platform" ) > $out_file if [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111 fi exec 0<$out_fileelse exec 0<$inp_filefi/bin/rm -f $inp_file $out_file# call spawn-filter so that features like# FILTERARGS, SPAMFILTER are not lostexec -a qmail-local /var/indimail/bin/spawn-filter "$@"exit 1111.5.5 valias / vfilter script #!/bin/sh# create a temporary fileinp_file=`mktemp -p /var/tmp -t myfilteri.XXXXXXXXXXXXXXX`if [ $? -ne 0 ] ; then /bin/rm -f $inp_file exit 111fiout_file=`mktemp -p /var/tmp -t myfiltero.XXXXXXXXXXXXXXX`if [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111fi/bin/cat > $inp_fileif [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111fisubject=`/var/indimail/bin/822header -I Subject < $inp_file`echo $subject | grep "failure notice" > /dev/null 2>&1if [ $? -eq 0 ] ; then ( /var/indimail/bin/822header < $inp_file echo echo "sorry about that" /var/indimail/bin/822body < $inp_file echo "sent by IndiMail Messaging platform" ) > $out_file if [ $? -ne 0 ] ; then /bin/rm -f $inp_file $out_file exit 111 fi exec 0<$out_fileelse exec 0<$inp_filefi/bin/rm -f $inp_file $out_file## unset RPLINE so that maildirdeliver does not add a duplicate Return-Path line# unset PWSTRUCT so that password structure cached is removed for vuserinfo to# work correctly#unset RPLINE PWSTRUCTdir=`/var/indimail/bin/vuserinfo -d [email protected] | cut -d: -f2 |cut -c2-`if [ $? -ne 0 -o " $dir" = " " ] ; then echo "unable to get user's homedir" 1>&1 exit 111fiexec /var/indimail/bin/maildirdeliver "$dir"/Maildirexit 111 [Less]