Re: [Dbmail-dev] Strange attachment

2005-09-22 Thread Paul J Stevens


Oleg wrote:
 Hello
 
 I use kmail and dbmail-2.0.7
 
 When I attach file with russian characters in file-name, I get such mime 
 header:
 
  Content-Type: application/msword;
   name*=koi8-r''%F0%D2%C1%D7%C9%CC%C1%20%CB%C1%CE%C1%CC%C1%2019%2E09%2Edoc
  Content-Transfer-Encoding: base64
  Content-Disposition: attachment;
   filename*=koi8-r''%F0%D2%C1%D7%C9%CC%C1%20%CB%C1%CE%C1%CC%C1%2019%2E09%

I'm no expert when it comes to utf7 encoding, but these headers don't
look valid at all. Did these headers come from a message stored in
dbmail already, or straight from kmail? Especially the parameters in
Content-Type and Content-Disposition don't look kosher: weird parameter
names and missing chars at the end.

 
 and kmail eat all memory, when I try to read this message. Thunderbird 
 can't 
 read this mail at all.
 
 But when I send this file by Thunderbird, mime header of attachment is:
 
  Content-Type: application/octet-stream;
  name==?KOI8-R?Q?=F0=D2=C1=D7=C9=CC=C1_=CB=C1=CE=C1=CC=C1_19=2E09=2Edoc?=
  Content-Transfer-Encoding: base64
  Content-Disposition: attachment; 
 filename==?KOI8-R?Q?=F0=D2=C1=D7=C9=CC=C1_=CB=C1=CE=C1=CC=C1_19=2E09=2Edoc?=
 
 and I can read this mail by kmail and thunderbird.

And now suddenly the headers look better.

 
 Why kmail put name*= in mime header of attach? And why I can't read such mail 
 by kmail?

Indeed. I'd say you hit a kmail bug. It's utf7 encoding routines may be
broken. Looks like stack corruptions to me.


-- 
  
  Paul Stevens  paul at nfg.nl
  NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31
  The Netherlandshttp://www.nfg.nl


Re: [Dbmail-dev] Mail filtering patch for DBMail 2.0.7

2005-09-22 Thread Paul J Stevens


Eugene Prokopiev wrote:
 Hi,
 
 There are no suitable way for mail filtering with DBMail. Sieve support
 is not stable and excluded by default, procmail will slow perfomance by
 invoking another process ...

Well, procmail is not that slow. It's mainly that procmail is not
suitable for lmtp.

 
 So, I write very simple filtering engine for DBMail. It's attached and
 based on this new table:


 - dsn_result = sort_and_deliver(tmpmsgidnr, msgsize, 
 useridnr, delivery-mailbox);
 +  
 + dsn_result = sort_and_deliver(tmpmsgidnr, msgsize, 
 useridnr, 
 + db_get_mailbox_from_filters(useridnr, 
 headerfields, delivery-mailbox));

Ok, so if you do that, what happens if the new tables are not in place?
Let's see:

 +char *db_get_mailbox_from_filters(u64_t useridnr, struct list *headerfields, 
 const char *mailbox)
 +{
 + trace(TRACE_MESSAGE, %s, %s: default mailbox [%s], __FILE__, 
 __func__, mailbox);
 + 
 + if (mailbox == NULL)

Mmm. So you're not overriding dbmail-smtp -m MAILBOX. Good.

 + {
 + unsigned i = 0; 
 + unsigned num_filters = 0;
 + 
 + snprintf(query, DEF_QUERYSIZE,
 + SELECT filter_field, filter_value, mailbox FROM 
 dbmail_filters WHERE user_id = '%llu' ORDER BY filter_id,
 + useridnr);
 + 
 + if (db_query(query) == -1) {
 + trace(TRACE_ERROR, %s,%s: error gettings filters for 
 + user_id [%llu], __FILE__, __func__,
 + useridnr);
 + return NULL;
 + }

Looks ok to me.

 + 
 + num_filters = db_num_rows();
 + for (i = 0; i  num_filters; i++) {
 + 
 + struct element *el = list_getstart(headerfields);
 + char *filter_field = db_get_result(i, 0);
 + char *filter_value = db_get_result(i, 1);
 + char *mailbox = db_get_result(i, 2);
 + 
 + trace(TRACE_MESSAGE,
 + %s, %s: filter [%s : \%s\ = %s],
 + __FILE__, __func__, filter_field, filter_value, 
 mailbox);
 + 
 + while (el) {
 + struct mime_record *record = (struct 
 mime_record *) el-data;
 + 
 + if (!strcmp(record-field, filter_field)  
 strstr(record-value, filter_value))
 + return mailbox;
 + 
 + el = el-nextnode;
 + }
 + }
 + 
 + db_free_result();
 + 
 + return NULL;
 + }
 + else
 + {
 + return NULL;
 + }
 +}

Only change I would suggest is calling db_get_mailbox_from_filters from
within sort_and_deliver.


-- 
  
  Paul Stevens  paul at nfg.nl
  NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31
  The Netherlandshttp://www.nfg.nl


Re: [Dbmail-dev] Mail filtering patch for DBMail 2.0.7

2005-09-22 Thread Eugene Prokopiev

Paul J Stevens wrote:

Ok, so if you do that, what happens if the new tables are not in place?


The best way to resolve this problem is another configuration parameter 
for filtering turned off by default. This may be useful for perfomance 
reasons. But in this case DBMail must not confuse about absent parameter 
in configuration file. Is this behaviour possible?



Only change I would suggest is calling db_get_mailbox_from_filters from
within sort_and_deliver.


It's sensible.


Need I change my patch or you will make this changes?

Do you have plans to place my patch to dbmail.org into download area or 
within dbmail source archive in separate file?


--
Regards,
Eugene Prokopiev


[Dbmail-dev] Re: Strange attachment

2005-09-22 Thread Oleg
   Content-Type: application/msword;
  name*=koi8-r''%F0%D2%C1%D7%C9%CC%C1%20%CB%C1%CE%C1%CC%C1%2019%2E09%2Edoc
  Content-Transfer-Encoding: base64
   Content-Disposition: attachment;
   
  filename*=koi8-r''%F0%D2%C1%D7%C9%CC%C1%20%CB%C1%CE%C1%CC%C1%2019%2E09%

 I'm no expert when it comes to utf7 encoding, but these headers don't
 look valid at all. Did these headers come from a message stored in
 dbmail already, or straight from kmail? Especially the parameters in
 Content-Type and Content-Disposition don't look kosher: weird parameter
 names and missing chars at the end.

Yes, this headers come from kmail.

  Why kmail put name*= in mime header of attach? And why I can't read such
  mail by kmail?

 Indeed. I'd say you hit a kmail bug. It's utf7 encoding routines may be
 broken. Looks like stack corruptions to me.

But, may be write workaround in dbmail?
If dbmail can undestand name*= and filename*= syntax - it will be good !

__
Oleg



Re: [Dbmail-dev] Re: Strange attachment

2005-09-22 Thread Paul J Stevens
Oleg wrote:
 
 But, may be write workaround in dbmail?
 If dbmail can undestand name*= and filename*= syntax - it will be good !

Hahaha! Good joke!

Sorry. But that's just such a bad idea for more than one reason. I mean, if it
were outlook, I (have) might (to) consider, but kmail is open-source. No reason
for the kmail community not to fix this. Au contraire! If kmail generates buggy
headers, do other imap-server accomodate such a mess? I be damned if they do.

Dbmail's own home-grown mime parser is a bitch to maintain, and for that reason
alone it's deprecated. If you find a bug please do report and we can fix it
together. But I'm not going to touch that code so we can accomodate bugs in
other people's closets.

Fixing kmail's utf7 code is probably easier to fix than creating a work-around
in dbmail. Also, such a work-around is deprecated before it written: dbmail-2.2
will use none of the mime code you see in dbmail-2.0, so for dbmail-2.2 you'd
have to write a totally new patch (against gmime, not dbmail).

In short; a waste of time better spent reporting this bug to the kmail crowd.

-- 
  
  Paul Stevens  mailto:[EMAIL PROTECTED]
  NET FACILITIES GROUP PGP: finger [EMAIL PROTECTED]
  The Netherlandshttp://www.nfg.nl


Re: [Dbmail-dev] Mail filtering patch for DBMail 2.0.7

2005-09-22 Thread Paul J Stevens
Eugene Prokopiev wrote:
 Paul J Stevens wrote:
 
 Ok, so if you do that, what happens if the new tables are not in place?
 
 
 The best way to resolve this problem is another configuration parameter
 for filtering turned off by default. This may be useful for perfomance
 reasons. But in this case DBMail must not confuse about absent parameter
 in configuration file. Is this behaviour possible?

Not necessary. You only need to handle db errors in db_get_mailbox_from_filters
gracefully: defaulting to mailbox=NULL, which you already do. I'd have to test
this, but I don't see any problems here. Perhaps remove or downgrade the trace
call after calling db_query.

 
 Only change I would suggest is calling db_get_mailbox_from_filters from
 within sort_and_deliver.
 
 
 It's sensible.
 
 
 Need I change my patch or you will make this changes?

Please do. I can make time to do it, but it's your patch.

 Do you have plans to place my patch to dbmail.org into download area or
 within dbmail source archive in separate file?

I'll include them first as dpatch file in debian/patches/02_simple_filters or
something like that.


-- 
  
  Paul Stevens  mailto:[EMAIL PROTECTED]
  NET FACILITIES GROUP PGP: finger [EMAIL PROTECTED]
  The Netherlandshttp://www.nfg.nl


Re: [Dbmail] Mail filtering patch for DBMail 2.0.7

2005-09-22 Thread Eugene Prokopiev

Jesse Norell wrote:

My filtering algorithm:

1) Read all filtering rules for current user with SELECT filter_field, 
filter_value, mailbox FROM dbmail_filters WHERE user_id = '%llu' ORDER 
BY filter_id


2) For every record read all mail headers and compare it with current 
record in dbmail_filters.


3) Apply destionation mailbox on founding first matching



  One thing that comes to mind that would be nice (if not absolutely
required) is the ability to order the filters, which from a cursory
look over the table setup, I don't think exists.  I guess if you wanted
to reorder 2 filters, you could delete the first and add it in again
with a higher filter_id, but it seems a bit awkward; just have an
adjustable sort priority and order by that.


This idea is already implemented :)

Filter records are ordered by filter_id during mail scan. You can change 
value of this field and so filters will be reordered.




  A couple other ideas that would be nice, but might complicate things,
are:  allow multiple entries with the same filter_id and a flag for
matching all or any (might need to add a unique index on the
filter_id and mailbox to make sure they're always consistent?).  Also
adding in a layer to pick your filtering type (eg. from dbmail.conf),
so you could choose simple dbmail_filter now, and later sieve or
others could be added (but that could be added later, when sieve is
ready, too).


Yes, this things are more complicated, so they will implemented than I 
need them.


I hope my code will merged with mail DBMail source tree so anybody will 
can use my code or change it. But I haven't answer in dbmail-dev 
maillist about my patch.


I know that adding new features in stable version is not good idea, but 
this feature is very needed for me and for other people which can't 
migrate to unstable DBMail version.



  Not being familiar with the code, does sort_and_deliver() get
called during IMAP APPEND's too, or just during smtp/lmtp?


I don't know :) I even don't know what is IMAP APPEND :) Can I do this 
operation in mail client?



--
Regards,
Eugene Prokopiev


[Dbmail] Tools for DBMail - Maildir/mbox conversion

2005-09-22 Thread Eugene Prokopiev

Hi,

Where can I find tools for DBMail - Maildir/mbox conversion?

--
Thanks,
Eugene Prokopiev


Re: [Dbmail] Mail filtering patch for DBMail 2.0.7

2005-09-22 Thread Paul J Stevens


Eugene Prokopiev wrote:

 I hope my code will merged with mail DBMail source tree so anybody will
 can use my code or change it. But I haven't answer in dbmail-dev
 maillist about my patch.

Sometimes I have to make a living :-)

 I know that adding new features in stable version is not good idea, but
 this feature is very needed for me and for other people which can't
 migrate to unstable DBMail version.

If this patch works out ok, I'll add it to the debian packages as a
dpatch. The main question is: how does this patch work for databases
that don't have the new filter table. But I'll have to read the patch
first I guess. If it degrades gracefully on existing installs, or
doesn't cause any regressions, there's no real reason not to include
such added features. Lets see how this works out first.

   Not being familiar with the code, does sort_and_deliver() get
 called during IMAP APPEND's too, or just during smtp/lmtp?

Just during delivery (smtp/lmtp). I just rewrote the append code in 2.1
last week, so I can tell you for sure it's a different beast all together.

sort_and_delivery is indeed the most obvious entry point for sorting. If
that breaks stuff like _imap_append, then _imap_append is broken (duh).

 I don't know :) I even don't know what is IMAP APPEND :) Can I do this
 operation in mail client?

Oh boy. What use is filtered delivery if you don't use imap???  So I
assume you do use imap. Append is what happens when you copy messages
from a folder in one account to another account or when your client
stores a sent message to the Sent folder.


-- 
  
  Paul Stevens  paul at nfg.nl
  NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31
  The Netherlandshttp://www.nfg.nl


Re: [Dbmail] Tools for DBMail - Maildir/mbox conversion

2005-09-22 Thread Jesse Norell
The tool to export straight from the database has not been
written yet, or at least not made generally available to
the dbmail community.  You could use fetchmail to do that
one mailbox at a time, looped in a script or something.


On Thu, 2005-09-22 at 09:31 +0400, Eugene Prokopiev wrote:
 Hi,
 
 Where can I find tools for DBMail - Maildir/mbox conversion?
 
 --
 Thanks,
 Eugene Prokopiev
 ___
 Dbmail mailing list
 Dbmail@dbmail.org
 https://mailman.fastxs.nl/mailman/listinfo/dbmail

-- 
Jesse Norell - [EMAIL PROTECTED]
Kentec Communications, Inc.