Skip to content

Instantly share code, notes, and snippets.

@jpommerening
Created March 20, 2017 13:27
Show Gist options
  • Save jpommerening/67a7de664fb0d608b0e22916af9b410a to your computer and use it in GitHub Desktop.
Save jpommerening/67a7de664fb0d608b0e22916af9b410a to your computer and use it in GitHub Desktop.
Some procmail patterns
LOGFILE=$HOME/procmail.log
VERBOSE=on
MAILDIR=/var/spool/imap/$LOGNAME
DEFAULT=./
TOP=.
SP=" "
SPC="[$SP]"
NSPC="[^$SP]"
# Subject line start (handling optional =?UTF-8?Q? tags)
ST="$SPC*(=([?][^?]+)+[?])?"
# Backup
# :0 c
# $TOP/backup/
##
## JIRA
##
## Match header
##
## Subject: [JIRA] (PROJ-123) Title
##
:0HD:
*$ ^$SPC*Subject:$ST\[JIRA\][_$SP]+[(]\/[A-Z]+
{
TARGETDIR=$TOP/JIRA/$MATCH
:0:
* ? test -d "$TARGETDIR" || mkdir "$TARGETDIR"
$TARGETDIR/
}
# Set status flag on mail
:0HDf
*$ ^$SPC*Subject:$ST\[JIRA\]
|formail -I"X-Status: F"
# ... and store in JIRA folder
:0a:
$TOP/JIRA/
##
## Buildbot
##
:0H:
* ^From:.*builds@travis-ci.org
{
TARGETDIR=$TOP/Travis
:0c
*$ ^$SPC*Subject:.*Passed:
$TARGETDIR/
:0a
* LASTFOLDER ?? ()\/[^/]+^^
|mv "$LASTFOLDER" "$TARGETDIR/cur/$MATCH:2,S"
:0:
$TARGETDIR/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment