On Mon, 24 Jun 2002 [EMAIL PROTECTED] wrote:

> 
> In a message dated: Mon, 24 Jun 2002 16:07:27 EDT
> Rich Payne said:
> 
> >On Mon, 24 Jun 2002, mike ledoux wrote:
> >
> >That's one way, however you'd be transfering the message to the client, 
> >figuring out where to put it and then sending it back again. What's would 
> >be even better would be just to move the message on the imap server. Yes 
> >you'd still have to pull the message down, but you wouldn't need to send 
> >it back again. So instead of giving putmail the entire message, just give 
> >it the message's unique message ID on the IMAP server and the destination 
> >folder.
> >
> >You would also need to be careful about maintaining message flags (unread 
> >etc....).
> 
> Doesn't IMAP have commands to only grab headers and to re-file a msg?
> If so, this shouldn't be all that difficult to implement with 
> procmail, since *most* filtering of e-mail is done on the headers.

Yes, you can grab just the header of a message. You can also just grab 
parts of the body. The body of an IMAP message is broken down into various 
'parts' and you can pull down these parts one at a time.
 
> Of course, I do wierd things like actually filter and sort based on 
> body content as well, which would then require tranferring the msg 
> from the server to the client for processing, then sending it back to 
> the server for filing.  A lot of overhead, but if IMAP has a properly 
> designed interface, it should be doable. 

No, there's no need to send it back. You could grab the header and the 
body (say just the text part of the body, leaving any attachments behind), 
filter based on that and then make a call to imap_mail_move to move that 
message into a different folder, no need to send that info back up to the 
server, it already there.

As I said before the only catch would be you'd need to manually reset the 
unseen flag in the destination folder as accessing the message from your 
INBOX would mark it as read, again it's just a matter of a call to 
imap_clearflag_full (I think that's right).

<insert dangerous and untested example code!>

<?php

if ($HTTP_SERVER_VARS[argc] == 3) {
        $argv_array=$HTTP_SERVER_VARS[argv];
        $message_id = $argv_array[1];
        $destination_folder = $argv_array[2];
        }
else {
        echo "You must pass this script 2 args, the message ID and the 
        destination folder name";
        exit();
}

$imap_conn=imap_open("hostname","user", "passwd");
imap_mail_move($imap_conn,$message_id,$destination_folder,CP_UID);
imap_clearflag_full($imap_conn,$message_id,"\\Seen",ST_UID);
imap_expunge($imap_conn);
imap_close($imap_conn);

?>

</dangerous and untested code>

So, the problem with the above is that you're making an imap connection 
for each message which is rather wasteful. An even better idea would be to 
move message en mass. In the above calls the $message_id could really be 
an imap sequence that would move multiple messages, that exercise is left 
to the reader (and of course error handling!).

--rdp


-- 
Rich Payne
http://talisman.mv.com


*****************************************************************
To unsubscribe from this list, send mail to [EMAIL PROTECTED]
with the text 'unsubscribe gnhlug' in the message body.
*****************************************************************

Reply via email to