Maildrop

From DreamHost
Jump to: navigation, search

maildrop is a mail delivery agent with filtering abilities.

In DreamHost you can use it as a mail filter, replacing procmail.

The instructions provided in this article or section require shell access unless otherwise stated.

You can use the PuTTY client on Windows, or SSH on UNIX and UNIX-like systems such as Linux or Mac OS X.
Your account must be configured for shell access in the Control Panel.
More information may be available on the article's talk page.

The instructions provided in this article or section are considered advanced.

You are expected to be knowledgeable in the UNIX shell.
Support for these instructions is not available from DreamHost tech support.
Server changes may cause this to break. Be prepared to troubleshoot this yourself if this happens.
We seriously aren't kidding about this.

Prerequisites

In DreamHost maildrop is only installed on the mail servers, not on the web servers to which you have shell access. You can still use it to filter incoming mail, since your home directory (and hence, your Maildir) are mounted on your mail server. The only caveat is that you have to use the $HOME shell variable to refer to your home directory, since it is mounted differently in the mail server than it is in your web server. That is, when you refer to $HOME from your shell, and when the mail server delivering mail to you refers to $HOME, both refer to the same physical location, however, the pathname is different (since both servers mount users' home directories in different mountpoints).

If you blindly trust your maildrop scripting abilities, you can go straight to #Filtering_mail_with_maildrop but, since you are not able to manually run maildrop, you won't be able to test how it is working.

Otherwise, keep reading in order to compile and install your own version of maildrop.

The other advantage of compiling and installing maildrop in your web server is that you can invoke it from web scripts or from Fetchmail.

Unix account setup

You have to prepare your shell account as shown in unix account setup.

Installing pcre

You also need the PCRE - Perl Compatible Regular Expressions library in order to compile maildrop.

  • Download and open the latest version of PCRE (the example will use version 8.02, current as of Jun 2010).
cd ${HOME}/soft
PCREVERS=8.02
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-${PCREVERS}.tar.bz2
tar xvjf pcre-${PCREVERS}.tar.bz2
cd pcre-${PCREVERS}
  • Configure, compile and install (remember that your environment must be set exactly as explained in unix account setup or else you'll have to change some of the options).
./configure --prefix ${RUN}
make
make check
make install

After make check verify that all tests passed... otherwise, check the error messages and see if you can find out what went wrong.

Now the PCRE library is installed in ${RUN}/lib, its header files in ${RUN}/include, a couple of utilities in ${RUN}/bin and the man pages distributed under ${RUN}/man.

Installing maildrop

  • Download and open the latest version of maildrop (the example will use version 2.5.0, current as of Jun 2010).
cd ${HOME}/soft
MDROPVERS=2.5.0
wget http://downloads.sourceforge.net/project/courier/maildrop/${MDROPVERS}/maildrop-${MDROPVERS}.tar.bz2

tar xvjf maildrop-${MDROPVERS}.tar.bz2
cd maildrop-${MDROPVERS}
  • Configure, compile and install.
./configure --prefix ${RUN} --with-etcdir=${RUN}/etc \
            --enable-trusted-users=102 --disable-authlib \
            --disable-syslog \
            CPPFLAGS="-I${RUN}/include" LDFLAGS="-L${RUN}/lib"
make
make install-strip
make install-man

Filtering mail with maildrop

Create a file with filtering instructions documented in http://www.courier-mta.org/maildrop/maildropfilter.html in your home directory called .mailfilter and test it manually using:

maildrop $HOME/.mailfilter

Once it works to your liking, add a file named .forward.postfix with one line like the following:

"| maildrop $HOME/.mailfilter "

And then make them only available to you using the following command:

chmod 0600 $HOME/.forward.postfix
chmod 0600 $HOME/.mailfilter

since, otherwise, the mail server (and maildrop) will not run it (and the mail will bounce).

After doing this, send yourself a message and verify that it gets through.