i need launch a script when receive an email with specific subject, i've try fetchmail + procmail, this my configuration
.fetchmailrc
set no bouncemail
defaults:
antispam -1
batchlimit 100
poll imap.googlemail.com protocol IMAP auth password
user "[email protected]" is root here
password 'xxxxx'
ssl
mda "/usr/bin/procmail -f %F -d %T";
.procmailrc
PATH=/bin:/usr/bin:/usr/local/bin:$HOME/bin:/usr/sbin
MAILDIR=/var/mail
LOGFILE=/var/log/procmail.log
:0
* ^Subject: "Test OK"
| echo "Test" >> /var/log/test.log
When send mail with subject Test OK
, i see in procmail log the lines:
From [email protected] Sat Dec 8 18:41:16 2018
Subject: Test OK
Folder: /var/mail/root 5304
But no execute the echo
, any ideas? Thanks
The
Subject
line in the log message doesn't have double quotes around it; hence, your regex didn't match.A better test is probably to save the entire message to a particular folder.
Perhaps see also Procmail degugging tips