Maildrop syntax

Paul tipped about using maildrop for creating server-side filters here, however how to make it work correctly?

Ownership of .mailfilter should be vpopmail / usergroup 750, right?

I now wonder about the syntax

if (/^Subject: .*Forums/)
{
   to "$IW_MAILDIR/.forums"
}

In the above, where do I set the $IW_MAILDIR-variable?

What would be the correct syntax to get emails with the subject-line of “forums” to get sent into Inbox.Forums? (as for this particular example)

Thanks

$IW_MAILDIR is set automatically for you. If you create a folder named “forums” in your mailbox, then the directory you would use is “.forums” like you have above. If you want to be absolutely sure what directory to use, ssh in and go to the user’s mail directory (/home/domainco/var/domain.com/emailuser/Maildir) and then do: ls -al. All the dot-folders are the subfolders of your mailbox.

Socheat

Would $IW_MAILDIR include “inbox”?

EDIT: I have added the code above into .mailfilter, yet it doesn’t filter the incoming mails matching the set criteria.

Hi

what are others keywords like Subject ?

to, from, contents, … are keywords ?

for example :
if (/^From: .mail@domain.com/) is correct ?

Pascal

I found these docs :
http://www.courier-mta.org/maildrop/documentation.html
http://www.courier-mta.org/maildrop/maildropfilter.html

If you have better links about maildrop filters syntax/lahguage do not hesitate to share them

Pascal

[QUOTE=Henrik;13769]Would $IW_MAILDIR include “inbox”?

EDIT: I have added the code above into .mailfilter, yet it doesn’t filter the incoming mails matching the set criteria.[/QUOTE]

$IW_MAILDIR points to your Inbox. Mail folder structure is a little quirky in Courier-IMAP (or maybe IMAP in general). Here’s an example email structure:


Inbox
 \_ Clients
     \_ Good
     \_ Bad
     \_ Ugly
 \_ Work
     \_ Todo
     \_ Notices
 \_ Personal
     \_ Friends
     \_ Family
     \_ Bills
         \_ 2006
         \_ 2007

and the matching directory structure on the server would be:


bash# pwd
/home/domainco/var/domain.com/mail/socheat/Maildir

bash # ls -a -1
.Clients
.Clients.Good
.Clients.Bad
.Clients.Ugly
.Work
.Work.Todo
.Work.Notices
.Personal
.Personal.Friends
.Personal.Family
.Personal.Bills
.Personal.Bills.2006
.Personal.Bills.2007

Again, $IW_MAILDIR is your inbox, so in this case, $IW_MAILDIR = /home/domainco/var/domain.com/mail/socheat/Maildir. To deliver mail to the “2007” folder of my Personal -> Bills folder, I would use:


   to "$IW_MAILDIR/.Personal.Bills.2007"

and to deliver to the inbox, you actually wouldn’t need to do anything. Any message that isn’t caught by the rules in the .maildrop file will default to being delivered to the inbox.

[QUOTE=pascal;13773]Hi

what are others keywords like Subject ?

to, from, contents, … are keywords ?

for example :
if (/^From: .mail@domain.com/) is correct ?

Pascal[/QUOTE]

It’s basically grepping the email headers for those patterns. So, just about anything in the email header is fair game for these rules. In the above case, you’d probably want to do:


if (/^From: .*mail@domain\.com/)

[QUOTE=IWorx-Socheat;13776]
Again, $IW_MAILDIR is your inbox, so in this case, $IW_MAILDIR = /home/domainco/var/domain.com/mail/socheat/Maildir. To deliver mail to the “2007” folder of my Personal -> Bills folder, I would use:


   to "$IW_MAILDIR/.Personal.Bills.2007"

and to deliver to the inbox, you actually wouldn’t need to do anything. Any message that isn’t caught by the rules in the .maildrop file will default to being delivered to the inbox.[/QUOTE]

I have followed your directions, however the emails won’t get delivered into the mailfolder at hand. What user/group access rights should .mailfilter be set as? Maybe it’s that which is spooking? (I think I got the syntax right)

The permissions on the file should be vpopmail.uniqname. Running:

~iworx/bin/varpermsfix.pex --domlist domain.com

should set the correct permissions for you (where domain.com is the account in question).

I added your example-code

if (/^Subject: .*forums/)
{
   to "$IW_MAILDIR/.forums"
}

And wrote an email with the subject “forums” after running “~iworx/bin/varpermsfix.pex --domlist mydomain.com”, yet it doesn’t filter to the proper folder :confused:

It’s case sensitive so make sure if you have /.forums the folder is lowercase on the IMAP

If Justec’s suggestion doesn’t help, open a ticket and we’ll take a look. We’ll need to root login, NodeWorx login, and the domain and email account in question.

Yes, I’ll open a ticket with the account information and the mailfilter in question that doesn’t want to work. I checked lowercaps, and the folder is in lowercaps as far as I can see.

EDIT: If I want to have matches on “forum” and “forums” I put in the below?

if (/^Subject: .*forum/)
{
   to "$IW_MAILDIR/.forums"
}

Nevermind, I got it to work now! hides

What did you do wrong?? C’mon you have to tell us so we dont make the same mistake as you :stuck_out_tongue:

Well, my first mistake - which is a bit emberassing is that I put the .mailfilter file inside “Maildir” :stuck_out_tongue: (yes yes, shame on me)

With that done, I saw that indeed I’ve had done some case-sensitive errors, though this was to do with the mail-header (Subject: ), it had to be a capital S, otherwise it wouldn’t work.

Then there was the permission-issue of the .mailfilter-file as well.

All in all, I didn’t think that the difference between a big or small letter would play such a big difference in the header-information.

How do I add “/” inside a filter rule?

I have a problem now with .mailfilter not working for one mailbox, and I don’t know why. It was working just fine until some day ago. (I issued a support ticket about it as well)