View previous topic :: View next topic |
Author |
Message |
LonelyStar Guru

Joined: 06 Dec 2005 Posts: 390
|
Posted: Thu Apr 10, 2008 6:44 pm Post subject: procmail, the MATCH variable and newline |
|
|
Hi,
I have several email addresses, and I sort incoming mail using procmail depending on the X-Mailbox header (which my smtp inserts):
Code: |
:0
* ^X-Mailbox: phpldapadmin$
/var/vpopmail/domains/lonely-star.org/ls/.maildir/.phpldapadmin/
:0
* ^X-Mailbox: conkeror$
/var/vpopmail/domains/lonely-star.org/ls/.maildir/.conkeror/
:0
* ^X-Mailbox: ot$
/var/vpopmail/domains/lonely-star.org/ls/.maildir/.ot/
...
|
My procmailrc is getting really full, and I have to add a newline everytime I add a new mail address. So I thought, a more generic way would be cool:
Code: |
:0
* ^X-Mailbox:[ \t]*\/[A-Za-z0-9]*$
/var/vpopmail/domains/lonely-star.org/ls/.maildir/.$MATCH/
|
The problem with this code is, that the MATCH variable includes the $ (newline) at the end. If the header is "X-Mailbox: ot", it results in this mailbox:
/var/vpopmail/domains/lonely-star.org/ls/.maildir/.ot
(without the trailing /), which makes procmail store the mail in mbox format (I wont it in maildir format).
If I remove the $:
Code: |
:0
* ^X-Mailbox:[ \t]*\/[A-Za-z0-9]*
/var/vpopmail/domains/lonely-star.org/ls/.maildir/.$MATCH/
|
The MATCH variable is always empty, resulting in
/var/vpopmail/domains/lonely-star.org/ls/.maildir/./
Also, not what I want.
Any Ideas on how to do this?
Thanks!
Nathan |
|
Back to top |
|
 |
Princess Nell l33t


Joined: 15 Apr 2005 Posts: 931
|
Posted: Thu Apr 10, 2008 9:16 pm Post subject: |
|
|
In your matching expression
Code: |
* ^X-Mailbox:[ \t]*\/[A-Za-z0-9]*
|
replace the trailing "*" with "+". The asterisk qualifier means "zero or more of the preceeding
expression", and procmail, unlike other regex engines, uses the shortest match - in this case
zero. The "+" qualifier OTOH means "one or more".
Please try it - although I have a sneaking suspicion the modification might yield only one letter
in MATCH, in which case you could try something like \/[^ \t]* (or \/[^ \t]+).
HTH. |
|
Back to top |
|
 |
LonelyStar Guru

Joined: 06 Dec 2005 Posts: 390
|
Posted: Thu Apr 10, 2008 9:23 pm Post subject: |
|
|
Hi,
Thanks for your reply. I do not really understand why, but
* ^X-Mailbox:[ \t]*\/[A-Za-z0-9]+
works ...
Thanks!
Nathan |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|