1

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 "test@test.com" 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 myemail@gmail.com  Sat Dec  8 18:41:16 2018
 Subject: Test OK
  Folder: /var/mail/root                             5304

But no execute the echo, any ideas? Thanks

hellb0y77
  • 955
  • 5
  • 11
  • 21
  • Does your personal `.procmailrc` really have the privileges to write to `/var/log/procmail.log`? This seems like a misconfiguration, either way. – tripleee Dec 08 '18 at 20:29

1 Answers1

1

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

tripleee
  • 1,324
  • 3
  • 14
  • 24