WebFaction
Community site: login faq

I'm trying to get procmail setup to work with +addresses, ideally any messages with a +tag for which there is already a folder created should be delivered into that folder but if an email arrives with a tag for which there is not a folder already that email should go into the ordinary inbox.

I can get any email with a +tag going into a folder with the tag name using:

ARG=$1
:0:
* ! ARG ^^^^
.$ARG/

But this creates the folders automatically so any new +tags would be auto created (but not I think auto subscribed in IMAP clients).

I found this which is meant to check that the directories exist and deliver to the inbox if not but I cannot get it to work on the webfaction servers I think this is because mailboxes do not get shell accounts on the mailservers.

:0:
* ! ? test -d .$ARG
{ $DEFAULT }
:0E:
.$ARG/

So my question is, am I right about the limitations for procmail and if so does anybody know of another way to achieve that behaviour.

asked 17 Mar '11, 22:58

GeorgeBrooke
1112
accept rate: 0%

Can you try with?

ARG = $1 :0 : * ARG ?? tag .$ARG/

You would have to do that for each of your tags but it will give the behavior as you desire.

Hope that helps!

(18 Mar '11, 00:34) neeravk

@neeravk I know about that way of doing it too but I was aiming to have something which could be controlled from the mail client without editing the procmailrc.

(18 Mar '11, 08:13) GeorgeBrooke

Depending on the email client that you are using, this should be possible with custom email rules in the mail client itself (though you will have to hard-code the tags/folders, rather than have them automatically detected/created). Note that this has nothing to do with procmailrc - procmailrc is a server-side filter, and it cannot be controlled by an email client.

(18 Mar '11, 08:32) tie

Yes I am aware how procmail works and of client side filters. That being said if procmail on the webfaction servers can be setup to check for the existance of a directory rather than automatically creating it, the behaviour of tags could be controlled from any IMAP client simply by creating or deleting folders.

(18 Mar '11, 10:09) GeorgeBrooke

I see what you mean. I don't think that procmail can do any checking of whether certain directory exists however - it will simply automatically create all the folders needed for email delivery.

(18 Mar '11, 10:18) tie

I'm getting around the problem by allowing procmail to create mailboxes and running the script similar to the one below to subscribe to them all from cron.

#!/usr/bin/env python2.6
import imaplib

MAILBOX = ''
PASSWORD = ''

M = imaplib.IMAP4_SSL(host='mail.webfaction.com')
M.login(MAILBOX, PASSWORD)

#Get a list of available mailboxes
boxes_imap = M.list()[1]
#Split IMAP response into list for mailbox names
boxes = set([ box.split('"')[-2]  for box in boxes_imap ])
print "Available mailboxes:"
print boxes

#Do the same for subscribes mailboxes
subed_imap = M.lsub()[1]
subed = set([ sub.split('"')[-2] for sub in subed_imap ] + ['INBOX'])
print "Subscribed mailboxes:"
print subed

new_boxes = boxes - subed

for box in new_boxes:
        M.subscribe(box)
        print "Subscribed to "+box

M.logout()
permanent link

answered 18 Mar '11, 12:08

GeorgeBrooke
1112
accept rate: 0%

Glad to hear you found a solution.

(18 Mar '11, 12:17) johns
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×261
×17
×8

question asked: 17 Mar '11, 22:58

question was seen: 2,855 times

last updated: 18 Mar '11, 12:17

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM