Automating Reprints with Procmail


In my previous post, I mention that I will email you a reprint of a paper, if you send an email to [Enable javascript to see this email address.]. I actually do nothing. The reprint is handled automatically using my Procmail. In this post I will explain how I got it to work.

The first thing to note is that my email supports sub-addressing. This means that in the above email address, the mail is delivered to “reed” with argument “2009b”. I use this argument to determine that the sender is looking for a PDF reprint of my recent paper.

Next I had to modify my .procmailrc to copy 2009b requests to a specific folder and reply to them with the paper. Here is my solution, which is based somewhat on the solution for vacation notice emails with Procmail.

PLUS=$1 #copy the sub-address into variable PLUS


* PLUS ?? ^2009b$
* !^X-Loop: reed+2009b@[snip]
* !^X-Spam-Status: Yes

   :0 A
   | (formail -r -A"From: reed@[snip]" -A"X-Loop: reed+2009b@[snip]" \
        -I"MIME-Version: 1.0" \
        -I"Content-Type: multipart/mixed; boundary=\"------------070504020300020208040609\""; \
      cat $HOME/papers/2009b.msg ) | $SENDMAIL -oi -t

This solution will copy and auto-reply to the incoming email if it matches the +2009b argument, is not from an email list, has not already been auto-replied to, and is not spam.

To send the reply, I use the formail tool that comes with Procmail to construct the reply. This involves using flags to specifying some email header variables, followed by catting a prespecified email body that contains the encoded attachment. I generated the body by sending myself the email and attachments that I wanted to send out to people, and then copying the body of the message to a text file, 2009b.msg. I just had to copy the boundary header used by my email program to the formail recipe above.

This rule can be expanded to autorespond to multiple requests and to handle formail or sendmail errors.

About this Entry

This page contains a single entry by Reed A. Cartwright published on May 26, 2009 6:39 PM.

Published: Antagonism between Local Dispersal and Self-Incompatibility Systems in a Continuous Plant Population was the previous entry in this blog.

June Conferences is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.


Powered by Movable Type 4.37