maildrop is a powerful and feature-rich tool Mail delivery agent for GNU/Linux.
vmail@host:~$ cd std.rocks/user/
vmail@host:~$ echo "|/usr/bin/maildrop" > .courier
Here is an example of a maildrop file that I use to automatically sort my emails. The goal is to move emails into specific directories automatically.
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/."
}
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/."
}
We can play a sound alert each time we receive 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`
}
Contact :