Hi all,

Using unique IDs to refer to messages in IMAP was needed by many 
developers (as I have seen on IRC). So here it is finally!


In IMAP a message can be accessed by its message number (which can 
change over time as messages are deleted and received) or by its unique 
ID (which usually never changes).


To enable using IDs, create the IMAP transport object with an extra option:

<code>
$imap = new ezcMailImapTransport( 'server', null, array( 
'uidReferencing' => true ) );
</code>

Alternatively you can set the option via an option object:
<code>
$options = new ezcMailImapTransportOptions();
$options->uidReferencing = true;

$imap = new ezcMailImapTransport( 'server' );
$imap->options = $options;
</code>

And then these methods can use unique IDs:
  - top()
  - expunge()
  - copyMessages()
  - fetchFlags()
  - setFlag()
  - clearFlag()
  - fetchAll()
  - fetchByMessageNr()
  - fetchFromOffset()
  - fetchByFlag()
  - sortFromOffset()
  - sortMessages()
  - searchMailbox()

In addition there is a new method (which also works with unique IDs 
based on the uidReferencing option):
  - fetchSizes() - get the sizes of the specified messages (so you don't 
have to call listMessages() which gets the sizes for ALL messages from 
the currently selected mailbox)


Examples:

- if uidReferencing is disabled (default), then nothing is changed:
<code>
$src = $imap->top( 1 );
</code>

- if uidReferencing is enabled, then:
<code>
$src = $imap->top( 325 );
</code>

where 1 is the message number, and 325 is the message unique ID (of the 
same message).


Unfortunately this is not possible in POP3, even though POP3 has unique 
IDs for messages as well (unless there are undocumented commands which 
do not appear in the RFCs).


Please try it out and please report any problems. Thank you.

We are still before the alpha1 so things can still be changed (if you 
don't like the code or the name of the option please say so :)

Cheers,
Alex.

-- 
Alexandru Stanoi
eZ Components System Developer
eZ Systems | http://ez.no
-- 
Components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/components

Reply via email to