Maildrop

Configuration

Intro

Here is a maildrop example file that I use to automaticly sort my e-mails. The goal is to automatically move email into specifics directories.

My maildrop file

logfile "/var/log/maildrop.log"
#log "MAILDIR : $MAILDIR"

import RECIPIENT
import HOME

log "HOMME : $HOME"
#log "RECIPIENT : $RECIPIENT"
#log "FROM : $FROM"
VERBOSE="5"
SHELL=/bin/bash

DEFAULT="$HOME/Maildir/."

#######shebang@shebangthedolphins.net###########
`[[ $MATCH =~ .*@personal.com ]]`
if ( $RETURNCODE == 0 )
{
        to "$HOME/Maildir/.perso/."
}

#######work@shebangthedolphins.net###########

`[[ $MATCH =~ .*@toto.com ]]`
if ( $RETURNCODE == 0  && ( /^To: .*support@shebangthedolphins.net.*/ || /^Cc: .*tech@shebangthedolphins.net.*/ ) && ! /^To: .*bye@shebangthedolphins\.net.*/ )
{
	to "$HOME/Maildir/.toto/."
}

if ( /^To: .*insurance@shebangthedolphins.net.*/ || /^To: .*INSURANCE@SHEBANGTHEDOLPHINS.NET.*/ )
{
        to "$HOME/Maildir/.axa/."
}
if ( /^To: .*bank@shebangthedolphins.net.*/ )
{
        to "$HOME/Maildir/.bank/."
}
#######buy@shebangthedolphins.net###########
`[[ $MATCH =~ .*@.*ebay.(com|fr) ]]`
if ( $RETURNCODE == 0  && /^To: .*buy@shebangthedolphins\.net.*/ )
{   
    to "$HOME/Maildir/.ebay/."
}
`[[ $MATCH =~ .*@fnac.com ]]`
if ( $RETURNCODE == 0  && /^To: buy@shebangthedolphins\.net/ )
{   
    to "$HOME/Maildir/.fnac/."
}
`[[ $MATCH =~ .*@amazon.fr ]]`
if ( $RETURNCODE == 0  && /^To: buy@shebangthedolphins\.net/ )
{   
    to "$HOME/Maildir/.amazon/."
}
if ( /^To: flattr@shebangthedolphins\.net/ )
{   
    to "$HOME/Maildir/.flattr/."
}
if ( /^To: playstation@shebangthedolphins\.net/ )
{   
    to "$HOME/Maildir/.playstation/."
}

Whitelist

if ( /To: .*boby@shebangthedolphins.net.*/ && ( /^From:\s.*<(.*)>/ && !lookup(tolower($MATCH1), "/var/vmail/shebangthedolphins.net/boby/whitelist" ))) #to lower doesn't seems to be useful
{
        log "MATCH : $MATCH1"
        to "$HOME/Maildir/.Junk/."
}

Play a sound

We can play a sound (alert) each time we received a specific mail

root@host:~# apt-get install alsa-utils
root@host:~# aplay -l
root@host:~# aplay -L
#! /bin/bash

aplay -D front:CARD=Device,DEV=0 -t wav /usr/local/sbin/alert.wav
audio:x:29:vmail

I had ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM front:CARD=Device,DEV=0 and aplay: main:788: audio open error: Invalid argument errors so I had to create a sudo rule.

vmail   ALL=(ALL) NOPASSWD:/usr/local/sbin/play_sound.sh
if (  /^From: .*santa@claus.*/ || /^Subject: .*specific subject.*/ )
{
    `sudo /usr/local/sbin/play_sound.sh`
}
Licence Creative Commons
This website http://shebangthedolphins.net is licensed to the public under a licence Creative Commons Attribution licence.
Contact :