WebFaction
Community site: login faq

I'm trying to get the procmail filtering working for my setup, but I'm having a little trouble. To filter all emails that are destined for a particular email address (in a robust way) I'm trying to do:

:0:
* ? formail -c -xReceived: -xTo: -xCc: -xBcc: | grep -F "something@example.com"
.something/

but no email ever passes this test. I've tried many variants, but this variant works fine for me in a local shell. Interestingly

:0:
* ? grep -F "something@example.com"
.something/

works exactly as expected, so there's nothing wrong with the grep expression, however as soon as you do

:0:
* ? cat | grep -F "something@example.com"
.something/

it stops working. So the culprit appears to be the pipe symbol, but from what the million procmail resources on the internet tell me, there shouldn't be anything wrong with this.

What's going wrong?

asked 30 Mar '16, 18:47

risicle
215
accept rate: 0%


I suspect this might be because our mailbox user accounts do not have any shells assigned to them.

So, try adding SHELL=/bin/bash to the top of your procmail rules to see if that solves the problem.

You might also need to use the full path to formail, eg /usr/bin/formail.

Finally, if you're trying to match an address in any recipient header, you might consider you might consider using the ^TO_ shortcut that procmail provides for that purpose, eg:

:0:
* ^TO_something@example\.com 
.something/

Hope that helps!

permanent link

answered 30 Mar '16, 20:11

seanf
12.2k41836
accept rate: 37%

edited 30 Mar '16, 20:13

Perfect! Thankyou, it seems so obvious now...

(30 Mar '16, 21:15) risicle

You're very welcome!

(30 Mar '16, 21:21) seanf

(the only thing that ^TO_ doesn't catch is badly behaved mailing lists which only leave a clue as to their destination in the Received: header)

(30 Mar '16, 23:34) risicle
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×17
×3
×2
×1
×1

question asked: 30 Mar '16, 18:47

question was seen: 1,166 times

last updated: 30 Mar '16, 23:34

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM