'PHP Unknown: [UNAVAILABLE] FETCH Server error while fetching messages (errflg=2)
When running the following command once:
<?php
$imap_structure = imap_fetchstructure($mail_connection, $email_number);
?>
I get the following error message:
Unknown: [UNAVAILABLE] FETCH Server error while fetching messages (errflg=2)
To confirm that PHP's imap_fetchstructure
function was causing the error I used die();
after each imap_*
function from the top of the function moving down until I started receiving the error again. Here is a list of things I've checked:
- Each email message is successfully retrieved from Yahoo and added to the database as if nothing went wrong; the process is dependent on getting the structure of this email so on that alone I'm at a loss as to how something can work while also throwing an error.
- This literally just started happening randomly after having already tested my mail script on a few hundred emails (not all at once, in much smaller batches).
- Only happens with PHP's
imap_fetchstructure
function; when looped (e.g. for ten emails) the error will occur for each iteration. - Only occurring for the Yahoo mail server, other servers aren't triggering this error with the exact same code.
- The custom error handler fails to return the line number (though I know where the error is occurring.
- I tried suppressing the error by using
@imap_fetchstructure()
though the error was still being reported. - I tried sticking the code in to a
try {}
/catch (exception $e) {}
though, again, the error was still being reported. - I restarted my server and pulled a different IP just because that has worked in stupider situations though no dice.
- [Edit] The issue stopped little less than an hour after it started.
I've come across a few folks who have reported such as at Mozillazine:
I have recently started getting this "[UNAVAILABLE] UID FETCH Server error while fetching messages" too with my Yahoo account.
Their next post:
So today, without doing anything differently, the problem solved itself. That seems to say it was on Yahoo's end but it's still odd that while it was happening in Thunderbird it wasn't happening in other email clients.
Beyond literally hard-coding my custom error handler to ignore this error how do I suppress or code my system to better handle this situation?
Solution 1:[1]
Had a similar issue (not with programming) with Yahoo (in Thunderbird) and found this answer. Don't know if it would apply to your situation:
You can try to reduce the "Maximum number of connections to cache" for any of the affected Yahoo account(s). The option is in Account Settings -Server Settings - Advanced. Mine is set to a value of 3 (was 5), which works for Yahoo.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Rumplestiltskin |