Horde-Procmail-Filters

From Qmail Info Wiki

Horde (http://www.horde.org) is a PHP-based application framework that includes IMP (Internet Messaging Program) (http://www.horde.org/imp/) for webmail, Turba (http://www.horde.org/turba/) for address book management, and Ingo (http://www.horde.org/ingo/) for email filter management.

Table of contents

Assumptions

  • Qmail + Vpopmail are installed and you are at least somewhat familiar with how they actually work.
    • I recommend using the Qmail Rocks (http://www.qmailrocks.org) installation guide, but substituting John Simpson's latest Combined Patchset (http://qmail.jms1.net/patches/combined.shtml) in the instructions.
  • You have some knowledge of how to administer a *NIX box.
  • Horde + IMP + Ingo (and possibly Turba) is already installed and working on your server
  • procmail (http://www.procmail.org) is installed
    • Type procmail -v to test.
  • safecat (http://jeenyus.net/~budney/linux/software/safecat.html) is installed in /usr/local/bin/
    • Type /usr/local/bin/safecat to test

Files

  • preprocmail: a script to check if .procmailrc exists for the recipient before we call procmail.
  • Scripts for pure-ftpd to authenticate against vpopmail.
    • ftpauth.php: a php command line script to be called by pure-authd (part of pure-ftpd) to verify vpopmail l/p (DEPRECIATED, DO NOT USE)
    • ftpauth: a bash script replacement for the above script. This will work regardless of your vpopmail setup (mysql, no mysql, etc)
  • /etc/procmailrc: the system wide procmailrc file which procmail will read before it does anything else
  • horde/ingo/config/backends.php: The file where we tell Horde/Ingo to use procmail and where to upload the .procmailrc file.

Introduction

In this howto, we will setup Horde/IMP/Ingo to generate procmail rules and upload them to the proper user's directory, we will configure procmail to deliver/filter incoming mail (per user, not globally), as well as install/configure PureFTPd to authenticate against the email user database.

Installing/Compiling PureFTPD

We will be configuring PureFTPD strictly for the use of horde. We will not be using this ftp server for normal system accounts, and we will have it setup to listen on localhost only (unless your webmail server is seperate from your mail server).

Download PureFTPD to your server:

Extract, configure and compile the source:

 tar zxvf pure-ftpd-1.0.20.tar.gz
 cd pure-ftpd-1.0.20
 ./configure --with-extauth --with-privsep --without-inetd
 make
 make install

We now have the pure-ftpd binaries installed in /usr/local/sbin and /usr/local/bin/

Installing the Authentication script


cd /usr/local/sbin
wget http://www.qmailinfo.org/scripts/ftpauth
chmod +x ftpauth

Edit the script to make sure that your vpopmail path is correct. You can view the script here


Configuring/Starting Pure-FTPD

Launch pure-authd:

  • /usr/local/sbin/pure-authd -s /var/run/ftpd.sock -r /usr/local/sbin/ftpauth &

Launch pure-ftpd:

  • /usr/local/sbin/pure-ftpd -0 -B -A -E -H -S 127.0.0.1,2121 -lextauth:/var/run/ftpd.sock

Remember to put these commands in your startup scripts. Test to make sure pure-ftpd is authenticating your vpopmail users:



[root@mail ~]# ftp localhost 2121
Trying ::1...
ftp: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.keystreams.com.
220---------- Welcome to Pure-FTPd [privsep] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 22:08. Server port: 2121.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (localhost:volfman): volfman@keystreams.com
331 User volfman@keystreams.com OK. Password required
Password:
230-User volfman@keystreams.com has group access to:  vchkpw
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/" is your current location
ftp> dir
229 Extended Passive mode OK (|||17475|)
150 Accepted data connection
drwx------   51 1009     vchkpw       1536 Aug 15 22:00 Maildir
-rw-------    1 1009     vchkpw          4 Feb  9  2004 lastauth
226-Options: -l
226 2 matches total
ftp> ls .procmailrc
229 Extended Passive mode OK (|||5394|)
150 Accepted data connection
-rw-r--r--    1 1009     vchkpw       1961 Aug 14 22:50 .procmailrc
226-Options: -l
226 1 matches total
ftp>

Install the preprocmail script

cd /usr/local/bin
wget http://www.qmailinfo.org/scripts/preprocmail
chmod +x preprocmail

Configuring Horde/Ingo

  • Backup your existing horde/ingo/config/backends.php and use the provided backends.php (http://www.qmailinfo.org/configs/backends.php.txt)

That should do it. Login to horde as a user and try creating a new filter. You should see a .procmailrc file appear in the user's directory in /home/vpopmail/domains/DOMAIN/USER/ and you should also see a /home/vpopmail/domains/DOMAIN/.qmail-USER created.