Skip to content

Instantly share code, notes, and snippets.

@nikushi
Created August 30, 2012 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikushi/3522545 to your computer and use it in GitHub Desktop.
Save nikushi/3522545 to your computer and use it in GitHub Desktop.
受信メールを日付フォルダにコピーするmaildropレシピ
HOME="/home/nikushi"
ARCHIVEBASE="$HOME/Maildir.Archives"
# parse Date: value
D=`egrep ^Date: | \
sed -e 's/^Date: *//' | \
perl -MDate::Parse -ne 'print Date::Parse::str2time("$_")' \
| perl -ne '@t=localtime($_); printf("%d%02d%02d",@t[5]+1900,@t[4]+1,@t[3])'`
if ( "$D" eq "" )
{
log "[WARN] D=$D, cannot get date on Date header, this mail is not archived."
cc "/dev/null"
}
else
{
OUT="$ARCHIVEBASE/.$D"
RET=`[ ! -d $OUT ] && /usr/local/bin/maildirmake $OUT && echo $OUT created`
log $RET
cc $OUT
}
#to "/dev/null"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment