Home » Php » Zend Framework IMAP: how to delete message by unique ID?

Zend Framework IMAP: how to delete message by unique ID?

Posted by: admin October 26, 2017 Leave a comment

Questions:

I’m using Zend Mail to interact with GMail.
Basically I simply fetch mail and move it to trash folder, then call expunge.

I do not like way when I need to process message and delete id message #1 using Zend\Mail\Storage::removeMessage() call. Method description says I should use unique ids (see getUniqueId()) if possible, however on new accounts unique ids are very close to non-unique ids.

For example, on new account we have following email messages:

Unique id | Id | Subject
1         | 1  | Welcome to Gmail!
2         | 2  | Important report 1
3         | 3  | Important report 1

Now I delete message #1 and see following structure:

Unique id | Id | Subject
2         | 1  | Important report 1
3         | 2  | Important report 1

When I call Zend\Mail\Storage::removeMessage(3) it responds that no such message can be found.

What is proper way to work with IMAP accounts asynchronously?

Answers:

Leave a Reply

Your email address will not be published. Required fields are marked *