Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
procmail, the MATCH variable and newline
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
LonelyStar
Guru
Guru


Joined: 06 Dec 2005
Posts: 390

PostPosted: Thu Apr 10, 2008 6:44 pm    Post subject: procmail, the MATCH variable and newline Reply with quote

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
View user's profile Send private message
Princess Nell
l33t
l33t


Joined: 15 Apr 2005
Posts: 931

PostPosted: Thu Apr 10, 2008 9:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
LonelyStar
Guru
Guru


Joined: 06 Dec 2005
Posts: 390

PostPosted: Thu Apr 10, 2008 9:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
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