# Procmail semi-working

## Gushy

Ok,  I've got procmail installed and set up on my server (with postfix and courier-imap).

I've set up my rc.subscriptions and some of the recipes seem to be working and some don't.

Below is a copy of my rc.subscriptions, maybe someone else can see problems with it (quite possible as this is only the second time I've ever used procmail and the first time I had one recipe). I've put comments in so you can see what I was trying to do.

Two of the recipes that I know work are the ones for 'oistins' and 'nPulse'.

```

####################################

## Transystel Emails

# email from tango

:0:

* ^From:.*tango      # look for tango in sender's address

.Work.Clients.Transystel.Tango/

# email from haribo

:0:

* ^From:.*haribo   # look for haribo in sender's address

.Work.Clients.Transystel.Haribo/

# email from chesham

:0:

* ^From:.*chesham   # look for chesham in sender's address

.Work.Clients.Transystel.Chesham/

# Red Hat Network Alerts

:0:

* ^From:.*rhn      # look for rhn in sender's address

.Work.Red\ Hat\ Network/

####################################

## LAN Emails

# email from holetown

:0:

* ^From:.*holetown   # look for holetown in sender's address

.LAN\ System\ Logs.Holetown/

# email from oistins

:0:

* ^From:.*oistins   # look for oistins in sender's address

.LAN\ System\ Logs.Oistins/

#nPulse Alerts

:0:

* ^Subject:.*nPulse   # look for nPulse in subject line

{

  :0c

  ! gushy@o2.co.uk

  :0

  .LAN\ System\ Logs.nPulse/

}

######################################

## Subscriptions

# comics

:0:

* ^From:.*comic      # look for comic in sender's address

.Subscriptions.Comics/

# Linux User Bulletin

:0:

* ^From:.*linuxuser   # look for linuxuser in sender's address

.Subscriptions.Linux\ User\ Bulletin/

# Linux World Newsletters

:0:

* ^From:.*idgnetnewsletters   # look for idgnewsletters in sender's address

.Subscriptions.Linux\ World/

# Gentoo Weekly Newsletter

:0:

* ^Subject:.*gwn   # look for gwn in subject line

.Subscriptions.Gentoo\ Weekly\ Newsletter/

# ZDNet Week

:0:

* ^From:.*mailmaster@zdnet-newsletterservice.co.uk   # look for sender's address

.Subscriptions.ZDNet/

# Games Domain Newsletters

:0:

* ^Subject:.*Games\ Domain\ Newsletter   # look for subject line

.Subscriptions.Games\ Domain\ \&\ Games\ Industry/

# GamesIndustry.biz Update

:0:

* ^Subject:.*GamesIndustry.biz\ Weekly\ Update   # look for subject line

.Subscriptions/Games\ Domain\ \&\ Games\ Industry/

# Pure-FTP Mailing List

:0:

* ^Subject:.*[pureftpd]      # look for [pureftpd] in subject line

.Subscriptions.PureFTPD/

# Courier-IMAP Mailing List

:0:

* ^Subject:.*[courier-users]   # look for [courier-users] in subject line

.Subscriptions.Courier-Imap/

#####################################

## Job Crap

# Jobsite Emails

:0:

* ^From:.*jobsite      # look for jobsite in sender's address

.Work.Job\ Hunting/

# Jobserve Emails

:0:

* ^From:.*jobserve      # look for jobserve in sender's address

.Work.Job\ Hunting/

# CW Jobs Emails

:0:

* ^From:.*cwjobsmail.co.uk   # look for cwjobsmail.co.uk in sender's address

.Work.Job\ Hunting/

# Go Jobsite Email Alerts

:0:

* ^Subject:.*GoJobsite\ Jobs-by-Email\ Alert   # look for subject line

.Work.Job\ Hunting/

# IT Jobs

:0:

* ^Subject:.*IT\ jobs      # look for IT jobs in subject line

.Work.Job\ Hunting/

```

Anyone see any problems? got any ideas?

Thanks.

----------

## compu-tom

I don't know Courier, but for me there are several "magic" lines...

.Subscriptions.Games\ Domain\ \&\ Games\ Industry/

   vs.

.Subscriptions/Games\ Domain\ \&\ Games\ Industry/

* ^Subject:.*[pureftpd]

   This means  it matches every subject with one letter from the range pureftpd. That is, with "p" or "u" or ... The same holds for [courier-users].

Are you really sure you need white spaces and Ampersands in the folder names?

----------

## Gushy

The folder name is .Subscriptions.Games Domain & Games Industry/   In courier the subfolders are seperate folders with the parent name & child name seperated by a .

ie:

Subscriptions                                   -  .Subscriptions/

       |---> Games Domain                  -  .Subscritpions.Games Domain/

 I have put \'s where I think they are needed.  I could rename the folder to remove white spaces and the &,  but that's kinda cheating.  :Wink: 

Thanks for the tip on the [pureftpd] & [courier-users], I had not thought about the [ ]'s being read as regular expressions (don't know much about regex if I'm honest), can I just escape them with a  \?  The rule will work without the [ ]'s, so I'll remove them, I'm just curious now.  :Smile: 

----------

## compu-tom

I see, but I'm just wondering about the use of / and . to mark the folder hierarchy as in Subscriptions.Games and Subscriptions/Games, respectively. Are they treated the same?

Not using spaces and other characters that needs to be quoted/escaped makes code always more readable.

Regexp are a great thing. They are worth learning about...  :Smile: 

----------

## Gushy

I assumed that I can't use / instead of . because the . are part of the directory names.  An imap folder that is a sub-folder of another imap folder, is not a sub-directory of another directory in the file system.  At least not with courier-imap.

I set up the imap folders before I decided to use procmail (previously I was just using filters in evolution) so my only worry was how they looked in evolution.  :Smile: 

*mental-note: must remember to read up on regexp!  :Wink: 

I just wasn't sure if I had read all the stuff on procmail right.  I wasn't sure if * ^From:.*xyz would only pick up xyz in the display name of who an email is from or whether it would pickup xyz in the sender's email address.  :Question: 

----------

## compu-tom

^From:.*xyz

matches the complete From: header line if it contains xyz anywhere on the line. If the line is

```
From: abc xyz <abcxyz@somewhere.com>
```

it would match xyz in the sender's name "abc xyz" and in her address "abcxyz@somewhere.com".

----------

## Gushy

That's what I thought, so my procmail setup must be flawed somewhere, because it doesn't seem to be working all the time.  :Sad: 

I've changed the recipe for emails with [courier-users] in the subject to read:

```

# Courier-IMAP Mailing List

:0:

* ^Subject:.*courier   # look for [courier-users] in subject line

.Subscriptions.Courier-Imap/ 

```

but it still doesn't seem to work, yet the rule that matches nPulse on the subject line works.   :Confused:  Any ideas why that might be?

The subject line from a mail on that mailing list reads:

```

Subject: [courier-users] testmxlookup failed

```

----------

## compu-tom

Mmm, I can't find an error.

What tells you the procmail log file?

Prepend

```
VERBOSE=yes

LOGFILE=/home/gushy/.procmail.log

```

to your .procmailrc and see if procmail states an syntax error.

----------

## Gushy

nope no syntax errors.  :Sad: 

I just sent a test mail from my user on that box, from header reads:

```

From: Nick Gushlow <nickg@oistins.barbados>

```

so that should get trapped by the 'oistins' recipe, but my log with verbose=yes reads:

```
procmail: [14285] Fri Jan 24 19:45:07 2003

procmail: Assigning "MAILDIR=/home/nickg/.maildir/"

procmail: Assigning "INCLUDERC=/home/nickg/Procmail/rc.subscriptions"

procmail: No match on "^From:.*tango            # look for tango in sender's address"

procmail: No match on "^From:.*haribo   # look for haribo in sender's address"

procmail: No match on "^From:.*chesham  # look for chesham in sender's address"

procmail: No match on "^From:.*rhn              # look for rhn in sender's address"

procmail: No match on "^From:.*holetown # look for holetown in sender's address"

procmail: No match on "^From:.*oistins  # look for oistins in sender's address"

procmail: No match on "^Subject:.*nPulse        # look for nPulse in subject line"

procmail: No match on "^From:.*comic            # look for comic in sender's address"

procmail: No match on "^From:.*linuxuser        # look for linuxuser in sender's address"

procmail: No match on "^From:.*idgnetnewsletters        # look for idgnewsletters in sender's address"

procmail: No match on "^Subject:.*gwn   # look for gwn in subject line"

procmail: No match on "^From:.*mailmaster@zdnet-newsletterservice.co.uk # look for sender's address"

procmail: No match on "^Subject:.*Games\ Domain\ Newsletter     # look for subject line"

procmail: No match on "^Subject:.*GamesIndustry.biz\ Weekly\ Update     # look for subject line"

procmail: No match on "^Subject:.*pureftpd              # look for [pureftpd] in subject line"

procmail: No match on "^Subject:.*courier               # look for [courier-users] in subject line"

procmail: No match on "^From:.*jobsite          # look for jobsite in sender's address"

procmail: No match on "^From:.*jobserve         # look for jobserve in sender's address"

procmail: No match on "^From:.*cwjobsmail.co.uk # look for cwjobsmai.co.uk in sender's address"

procmail: No match on "^Subject:.*GoJobsite\ Jobs-by-Email\ Alert       # look for subject line"

procmail: No match on "^Subject:.*IT\ jobs              # look for IT jobs in subject line"

procmail: Assigning "LASTFOLDER=/home/nickg/.maildir/new/1043437507.14285_0.oistins.barbados"

procmail: Notified comsat: "nickg@0:/home/nickg/.maildir/new/1043437507.14285_0.oistins.barbados"

From nickg@oistins.barbados  Fri Jan 24 19:45:07 2003

 Subject: testing again

  Folder: /home/nickg/.maildir/new/1043437507.14285_0.oistins.barbados      510

```

very strange.

----------

## compu-tom

What about the inline comments? What happens if you remove them (and put them on separate lines).

E.g.

```
# email from oistins

# look for oistins in sender's address

:0:

* ^From:.*oistins 

.LAN\ System\ Logs.Oistins/
```

? I suspect the comments are treated as patterns as well.

----------

## Gushy

Removing the inline comments did the trick!  :Very Happy: 

The irony? when I posted it wasn't working and I put the inline comments in so my post would be more readable.  So technically I've not changed my rc.subscriptions file.  Whether it continues to work well, only time will tell I guess.  I'll just keep firing test emails at it until it breaks.  :Wink: 

I've just noticed another weird problem though.  :Sad:   I'm beginning to dislike email!

Emails that are passed to procmail by getmail and don't match any recipies (the ones that match are dealt with ok), get dumped to /home/nickg/.maildir/msg.EAMB (EAMB differs for each message). rather than being put into my inbox.

Emails that aren't passed by getmail (ie local mails) and don't match recipies end up in my inbox.

Don't suppose you'd have any idea what that problem might be?  :Question: 

The only thing I can think of is that my getmailrc is wrong; the postmaster line in my getmailrc reads

```

postmaster = "/usr/bin/procmail /home/nickg/.procmailrc"

```

I'm a little stumped after rtfming, googling and searching on this forum as to what else it could be.   :Confused: 

----------

## compu-tom

I guess you will need to specify a DEFAULT mail dir. See promailrc(5).

----------

## Gushy

yes yes yes !!  :Mr. Green:  now all my procmail problems are solved.

You sir, are a star!  Thanks a lot for taking time out to help me.  :Smile: 

----------

