Tech Support > Operating Systems > Linux / Variants > procmail recipe question
procmail recipe question
Posted by Richard Kimber on January 28th, 2004


How do I formulate a procmail test for a non-existent
Subject: and/or an empty email body?
in an email

Thanks,
- Richard.

Posted by Ed Murphy on January 28th, 2004


On Wed, 28 Jan 2004 21:03:06 +0000, Richard Kimber wrote:

:0
* ^Subject: *$

:0 B
* ![^ ]

or

:0 B
* ![A-Za-z]

I think these will work, but I haven't tested them. In particular, I
don't know whether the body tests will hold up against attachments; the
following set should match any message with a non-text attachment:

:0 B
* ^Content-Type: [^t]

:0 B
* ^Content-Type: t[^e]

:0 B
* ^Content-Type: te[^x]

:0 B
* ^Content-Type: tex[^t]

International users may want to consider the A-Za-z part in more
detail. It may not be a substantive issue, though.


Posted by Richard Kimber on January 29th, 2004


On Wed, 28 Jan 2004 21:22:31 +0000, Ed Murphy wrote:

Thanks for replying. Maybe I didn't explain properly. I don't just mean
a blank subject but a missing line that starts Subject:
I assume the recipe given will match with
Subject:

- Richard.


Posted by Ed Murphy on January 29th, 2004


On Thu, 29 Jan 2004 00:24:58 +0000, Richard Kimber wrote:

:0
* !^Subject:


Posted by Cameron Simpson on January 29th, 2004


On 00:24 29 Jan 2004, Richard Kimber <rkimber@ntlworld.com> wrote:
| On Wed, 28 Jan 2004 21:22:31 +0000, Ed Murphy wrote:
| >> How do I formulate a procmail test for a non-existent
| >> Subject:
| >
| > :0
| > * ^Subject: *$
|
| Thanks for replying. Maybe I didn't explain properly. I don't just mean
| a blank subject but a missing line that starts Subject:
| I assume the recipe given will match with
| Subject:

I confess it took me a minute to figure out even the above sentence.

From the "man procmailrc" manual entry:

There are some special conditions you can use that are not straight
regular expressions. To select them, the first character of the condi-
tion must be a:

! Invert the condition.

So:

:0
* !^Subject:

Now, that _might_ fail. I hope it means:
there is no header line starting with "Subject:"
but it might mean
there's at least one header line that doesn't start with "Subject:"

I expect it to mean the former. Untested.

Cheers,
--
Cameron Simpson <cs@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

Then start making an effort to police your more clueless cohorts, and maybe I
won't have to play Godzilla in your pathetic backwater Tokyo of a newsgroup
anymore. The ball's in your court. - Geoff Miller

Posted by Ed Murphy on January 29th, 2004


On Thu, 29 Jan 2004 13:16:49 +1100, Cameron Simpson wrote:

Your expectation is correct. I use this rule to match bcc'ed mail:

:0
* !^(To|Cc):.*emurphy42@socal.rr.com


Posted by Richard Kimber on January 29th, 2004


On Thu, 29 Jan 2004 05:45:39 +0000, Ed Murphy wrote:

Thanks very much for the help.

- Richard Kimber



Similar Posts