imap
imap copied to clipboard
getHeaders() throws exception after moving message
I ave a script that is iterating over a message list and doing something like this to a message in Gmail:
$message->markAsSeen();
$message->move($this->mailboxes['[Gmail]/All Mail']);
echo 'Moving "' . $message->getSubject() . '" to All Mail and marking read' . PHP_EOL;
This throws an exception like:
PHP Fatal error: Uncaught Ddeboer\Imap\Exception\InvalidHeadersException: Message "110111" has invalid headers
Obviously I can work around this by getting the subject before moving the message, but still it seems like something that we'd like to fix. I see the $this->clearHeaders();
is called inside move()
— Could the headers be cached somewhere and possibly referenced after a move?
Could the headers be cached somewhere and possibly referenced after a move?
Mmm, it would be misleading: a message is identified within the mailbox that has it, if you change its mailbox you are, for the imap extension, referring to a different message.
And everything gets even more complicated if you expunge
, or not, the connection before the getSubject
call, or undelete
it.
I agree the current behavior is not very clear, but all the changes I think of would only put more mud on it.