Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get messages by UID sequence #373

Merged
merged 3 commits into from Dec 4, 2018
Merged

Conversation

LeadTechVisas
Copy link
Contributor

I needed to get Messages based on an UID sequence. imap_search and imap_sort don't support that, apparently you have to use imap_fetch_overview.

I added a method to the Mailbox object that lets you get a MessageIterator based on a sequence of ids.

This allows you to store the id of the last message you read an then later read only messages with a higher id than that.

foreach ( $mailbox->getMessageSequence($lastImported . ':*') as $message ) {

@Slamdunk Slamdunk added this to the 1.6 milestone Oct 26, 2018
Copy link
Collaborator

@Slamdunk Slamdunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice proposal: take a look at the additional tests I've required, and run php-cs-fixer to fix the coding standards please 👍

src/Mailbox.php Show resolved Hide resolved
tests/MailboxTest.php Show resolved Hide resolved
@LeadTechVisas
Copy link
Contributor Author

Thank you for the feedback. I just updated the PR.

@Slamdunk
Copy link
Collaborator

I think it is still missing the empty path, for example

$this->mailbox->getMessageSequence('99999:*')

@LeadTechVisas
Copy link
Contributor Author

99999:* will not return an empty array. A sequence containing * will always return the last message, even if the starting UID is higher than the last one. I added a test for 99998:99999.

@Slamdunk Slamdunk merged commit 6eee3d3 into ddeboer:master Dec 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants