<html lang="en"> <head> <title>Using Maildirs - BuildBot Manual - 0.8.4p1</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="BuildBot Manual - 0.8.4p1"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Mail_002dparsing-ChangeSources.html#Mail_002dparsing-ChangeSources" title="Mail-parsing ChangeSources"> <link rel="prev" href="Subscribing-the-Buildmaster.html#Subscribing-the-Buildmaster" title="Subscribing the Buildmaster"> <link rel="next" href="Parsing-Email-Change-Messages.html#Parsing-Email-Change-Messages" title="Parsing Email Change Messages"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- This is the BuildBot manual for Buildbot version 0.8.4p1. Copyright (C) 2005, 2006, 2009, 2010 Brian Warner Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.--> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Using-Maildirs"></a> <p> Next: <a rel="next" accesskey="n" href="Parsing-Email-Change-Messages.html#Parsing-Email-Change-Messages">Parsing Email Change Messages</a>, Previous: <a rel="previous" accesskey="p" href="Subscribing-the-Buildmaster.html#Subscribing-the-Buildmaster">Subscribing the Buildmaster</a>, Up: <a rel="up" accesskey="u" href="Mail_002dparsing-ChangeSources.html#Mail_002dparsing-ChangeSources">Mail-parsing ChangeSources</a> <hr> </div> <h5 class="subsubsection">4.7.3.2 Using Maildirs</h5> <p>A “maildir” is a simple directory structure originally developed for qmail that allows safe atomic update without locking. Create a base directory with three subdirectories: “new”, “tmp”, and “cur”. When messages arrive, they are put into a uniquely-named file (using pids, timestamps, and random numbers) in “tmp”. When the file is complete, it is atomically renamed into “new”. Eventually the buildmaster notices the file in “new”, reads and parses the contents, then moves it into “cur”. A cronjob can be used to delete files in “cur” at leisure. <p>Maildirs are frequently created with the <samp><span class="command">maildirmake</span></samp> tool, but a simple <samp><span class="command">mkdir -p ~/MAILDIR/{cur,new,tmp}</span></samp> is pretty much equivalent. <p>Many modern MTAs can deliver directly to maildirs. The usual .forward or .procmailrc syntax is to name the base directory with a trailing slash, so something like <code>~/MAILDIR/</code> . qmail and postfix are maildir-capable MTAs, and procmail is a maildir-capable MDA (Mail Delivery Agent). <p>Here is an example procmail config, located in ~/.procmailrc <pre class="example"> # .procmailrc # routes incoming mail to appropriate mailboxes PATH=/usr/bin:/usr/local/bin MAILDIR=$HOME/Mail LOGFILE=.procmail_log SHELL=/bin/sh :0 * new </pre> <p>If procmail is not setup on a system wide basis, then the following one-line <samp><span class="file">.forward</span></samp> file will invoke it. <pre class="example"> !/usr/bin/procmail </pre> <p>For MTAs which cannot put files into maildirs directly, the <samp><span class="file">safecat</span></samp> tool can be executed from a <samp><span class="file">.forward</span></samp> file to accomplish the same thing. <p>The Buildmaster uses the linux DNotify facility to receive immediate notification when the maildir's “new” directory has changed. When this facility is not available, it polls the directory for new messages, every 10 seconds by default. </body></html>