sergi_pinto
Are there two errors logged at the same time or only one? If there are two errors check the other one to see what it says and see if it matches what I said above; sometimes an additional API error is logged.
You can try logging the raw email content by editing this file and changing:
public function getRawEmail(int $i) {
return $this->getRawHeader($i) . $this->getRawContent($i);
}
... to:
public function getRawEmail(int $i) {
error_log($this->getRawHeader($i) . $this->getRawContent($i));
return $this->getRawHeader($i) . $this->getRawContent($i);
}
Be super careful though as this will log ALL email content for every fetched email. This could fill up your logs very quickly. Ideally you'd want to do this in low traffic hours and during low email counts.
Essentially, what you are looking for is either the full raw email of the mail that can't be fetched or an error returned from the mailserver. Typically when your issue happens you'll see an error saying something like Retrieval using the IMAP4 protocol failed for the following message
and The server couldn't retrieve the following message
and The message hasn't been deleted. You might be able to view it using either Outlook or Outlook Web App. You can also contact the sender to find out what the message says.
.
If you do see the full raw email then take a look at the headers for anything that might be malformed.
Cheers.