Hey Andrew - in the interrum, here is a patch to maildrop I wrote a while
ago - this is the original message... let me know how it works for you or if
you fix my bug? Thanks...
NOTE this is intended to create a subfolder - not a whole maildir - there
are a few things missing for a top level mail folder. You could add them
easily though.
m/
----
First, let me say C / C++ is not something I consider myself an expert
with...
I had a need to avoid the large volume of mail being saved as mailbox files
or deferred endlessly due to user error (moving / renameing / deleting
important folders like "Sent" / "Sent Items" / "Spam" etc.
Also, from a programatic point of view it seemed wastefull to shell out to
something else to test for / create mailfolders if needed, so I built this
patch.
If you use a trailing slash on the delivery folder in a mail filter, the
folder will be created by the first message delivered.
For this reason, I don't think it conflicts with the legacy of mailbox file
autocreation and delivery - files are not paths.
KNOWN BUG:
Although I copied the delivery code (or what I think is the delivery code)
from above, the first message does not seem to be delivered - maybe I copied
the wrong code??? The second and all other messages do get delivered though
and for my purposes this is good enough (better than massive backlogs and
manual fixes to 100's of maildirs). I would appreciate it if anyone can show
me my error though.
Thanks to Mark Constable for helping find the snipits of code I needed to
copy - I figured out where - he found an example of how... away we go!
TO USE:
Add something like this to your .mailfilter:
DEFAULT=/home/user1/Maildir
if (/^Subject: Test Filter/)
to "$DEFAULT/.TESTFILTER/"
m/
--- deliver.C.ORIGINAL Mon May 5 00:41:31 2003
+++ deliver.C Thu May 8 17:40:37 2003
@@ -52,6 +52,15 @@
DeliverDotLock dotlock;
Buffer b;
+//MSC 2003.05.01 PATCH "maildir subfolder autocreate" [EMAIL PROTECTED]
+// test if mailbox ends in a '/'
+// indicating that it should be a folder
+char *mailboxispath=strrchr(mailbox, '/');
+// set perm integer for use by code that creates new subfolders - same as
+// in maildrop source code directory
+int perm=0700;
+//MSC 2003.05.01 END "maildir subfolder autocreate" [EMAIL PROTECTED]
+
if ( *mailbox == '!' || *mailbox == '|' )
{
Buffer cmdbuf;
@@ -163,6 +172,43 @@
deliver_maildir.MaildirSave();
log(mailbox, 0, format_mbox);
}
+//MSC 2003.05.01 PATCH "maildir subfolder autocreate" [EMAIL PROTECTED]
+//
+// if mailbox is not a valid maildir AND the mailbox ends in a '/'
+// (see test above) then create the folder (code copied from
+// maildir/maildirmake.c
+ else if (!Maildir::IsMaildir(mailbox) && mailboxispath != NULL)
+ {
+ if (mkdir(mailbox, perm) < 0 ||
+ chdir(mailbox) < 0 ||
+ mkdir("tmp", perm) < 0 ||
+ chmod("tmp", perm) < 0 ||
+ mkdir("new", perm) < 0 ||
+ chmod("new", perm) < 0 ||
+ mkdir("cur", perm) < 0 ||
+ chmod("cur", perm) < 0 ||
+ open("maildirfolder", O_CREAT|O_WRONLY, 0600) < 0)
+ {
+//THIS CODE TAKEN FROM IF ELSE SECTION ABOVE
+ Maildir deliver_maildir;
+ Mio deliver_file;
+
+ if ( deliver_maildir.MaildirOpen(mailbox,
deliver_file,
+ maildrop.msgptr->MessageSize()) < 0)
+ throw 77;
+
+ format_mbox.Init(0);
+ if (format_mbox.DeliverTo(deliver_file))
+ {
+ log(mailbox, -1, format_mbox);
+ return (-1);
+ }
+ deliver_maildir.MaildirSave();
+ log(mailbox, 0, format_mbox);
+//END COPYING
+ }
+ }
+//MSC 2003.05.01 END "maildir subfolder autocreate" [EMAIL PROTECTED]
else // Delivering to a mailbox (hopefully)
{
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1
_______________________________________________
courier-users mailing list
[EMAIL PROTECTED]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users