SCS Computing
 Services and Solutions
  links to the SCS and CMU home pages Carnegie Mellon School of Computer Science Carnegie Mellon University
 » How to… 
 » Accounts & passwords 
 » AFS 
 » AV help 
 » Backups & restores 
 » Calendaring 
 » E-mail 
 » Networking 
 » Printing 
 » Purchasing 
 » Resource management 
 » Security 
 » Software licensing 
 » Support charges 
 » Support lifecycle 
 » Web publishing 
 » Mac support 
 » Linux support 
 » Windows PC support 

External Mail Processing with Corvid

Table of Contents

  • Preamble
  • Setting up a spool folder on the IMAP server
  • Configuring Fetchmail
  • Configuring Procmail
  • Interactive Use
  • Automating the Process


Because the IMAP component of Corvid is a stand-alone server, there is no integrated way for the server itself to write out mail to a particular filesystem. This can instead be done by clients run at the user's behest. The following instructions outline one method of doing this.

The underlying software to make this work is supported in the Facilities environments for Red Hat 9 and Fedora Core 3; if you have need of this functionality on other platforms, please contact the help desk.

Setting up a spool folder on the IMAP server

The Corvid mail server allows concurrent clients, and most IMAP clients expect to access the INBOX folder as the default for incoming mail.

Because of this, the first step required is to set up a seperate subfolder for sole use by the client that writes mail to a file. In this way, other clients will not interefere with the state of that folder, and the spooling client will get a complete copy of the mail stream.

Create the folder:


This folder can be created by any IMAP client, or with the cyradm command line utility.

The next step is to make sure that mail (as appropriate) gets delivered to the INBOX.SPOOL file in addition to any other processing. This is done via Sieve; an example sieve script to do this follows:

# This script moves spam, and then writes each incoming message to both
# the INBOX (for interactive clients) and INBOX.SPOOL (to be written
# to a filesystem).


if header :matches "X-Spam-Warning" "*"
        fileinto "INBOX.SPAM";
        fileinto "INBOX";
        fileinto "INBOX.SPOOL";

Mail will now be filed into both the INBOX (for interactive clients) and INBOX.SPOOL as a holding area.

For more information about sieve scripting, please see Sieve Scripts in the SCS Environment.

Configuring Fetchmail

The next step is to configure a client to pull mail from the dedicated mail folder.

Fetchmail is recommended for this. Fetchmail is available on all supported SCS Linux platforms.

Fetchmail configuration is kept by the default in a file '.fetchmailrc' in the user's home directory. The following is an example of a recommended .fetchmailrc: poll proto IMAP auth gssapi sslproto ssl3 mda "/usr/bin/procmail -t -m .procmailrc" folders INBOX.SPOOL no idle flush

This will pull down mail from the INBOX.SPOOL folder and then send it to procmail for local delivery, which is covered in the next step.

Note: be default, fetchmail is a fairly noisy program, and generates a lot of status messages. You may wish to run fetchmail with the -s switch.

Configuring Procmail

Procmail is used to accept mail from fetchmail, and then write the mail to a file. Procmail configuration is ept in a file '.procmailrc' in the user's home directory. An example .procmailrc file is as follows:


:0 fhw
# User-specific rules go here...
# And if no other rules matched, we deliver normally
# If delivery fails, report an error and drop the mail

This script will take delivery of mail from fetchmail, ensure correct mailbox-style formatting, and then append the mail to the file ~/Mail/INBOX. If for some reason procmail is unable to process the mail, the mail will be dropped.

Interactive Use

With the above configuration, to retreive mail from Corvid to the file "~/Mail/INBOX":


As above, fetchmail can be run with the -s switch to suppress output:

fetchmail -s

Note: valid kerberos tickets are required for fetchmail to operate.

Note: procmail requires valid AFS tokens to operate, if the spool file is in AFS.

Automating the Process

Fetchmail can be automatically run via several mechanisms. Cron is the usual solution, and is available in the facilities environment — please check the system documentation for the use of cron to automate tasks.

Whether you are spooling to a local disk or into AFS, fetchmail will still require valid tickets to access the Corvid server. For unattended operation, a ticket renewal utility like krenew is recommended.