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?
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.
I am having an issue when I have a php application that is returning an internal server error (500) however nothing is showing up in the error log.
Now I know there are error with what I am trying to run, I know I have missing some files and what not but something should show in the apache error log (otherwise how are I supposed to know exactly what I am missing).
I created a test script is errors it in under the same vhost configuration and those error show up fine so everything seems configured right as far as php/apache. Are there certain php errors that does show up in the error log (php is configure to display any type of notice, warning, , error, fatal error, etc...)?
This is running on ubunut 10.04 with the standard apache and php from the ubuntu repo with apt-get.
Scan your source files to find #.
From php documentation site
Currently the "#" error-control operator prefix will even disable
error reporting for critical errors that will terminate script
execution. Among other things, this means that if you use "#" to
suppress errors from a certain function and either it isn't available
or has been mistyped, the script will die right there with no
indication as to why.
Copy and paste the following into a new .htaccess file and place it on your website's root folder :
php_flag display_errors on
php_flag display_startup_errors on
Errors will be shown directly in your page.
That's the best way to debug quickly but don't use it for long time because it could be a security breach.
If you still have 500 error and no logs you can try to execute from command line:
php -f file.php
it will not work exactly like in a browser (from server) but if there is syntax error in your code, you will see error message in console.
Maybe something turns off error output. (I understand that you are trying to say that other scripts properly output their errors to the errorlog?)
You could start debugging the script by determining where it exits the script (start by adding a echo 1; exit; to the first line of the script and checking whether the browser outputs 1 and then move that line down).
In the past, I had no error logs in two cases:
The user under which Apache was running had no permissions to modify php_error_log file.
Error 500 occurred because of bad configuration of .htaccess, for example wrong rewrite module settings. In this situation errors are logged to Apache error_log file.
For Symfony projects, be sure to check files in the project'es app/logs
More details available on this post :
How to debug 500 Error in Symfony 2
Btw, other frameworks or CMS share this kind of behaviour.
Here is another reason why errors might not be visible:
I had the same issue. In my case, I had copied the source from a production environment. Hence the ENVIRONMENT variable defined in index.php was set to 'production'. This caused error_reporting to be set to 0 (no logging). Just set it to 'development' and you should start seeing error messages in apache log.
Turned out the 500 was due to a semi colon missing in database config :-)
Another case which happened to me, is I did a CURL to some of my pages, and got internal server error and nothing was in the apache logs, even when I enabled all error reporting.
My problem was that in the CURL I set
curl_setopt($CR, CURLOPT_FAILONERROR, true);
Which then didn't show me my error, though there was one, this happened because the error was on a framework level and not a PHP one, so it didn't appear in the logs.
You need to enable the PHP error log.
This is due to some random glitch in the web server when you have a php error, it throws a 500 internal error (i have the same issue).
If you look in the PHP error log, you should find your solution.
see here in the doc of how to enable it in the php.ini
Be sure your file permissions are correct. If apache doesn't have permission to read the file then it can't write to the log.
What happened for me when this was an issue, was that the site had used too much memory, so I'm guessing that it couldn't write to an error log or displayed the error. For clarity, it was a Wordpress site that did this. Upping the memory limit on the server showed the site again.
SOLVED
I struggled with this and later on, I realized that I was working on PHP 5.6, so I upgraded to PHP 7.0, then I released there were comments placed by git for conflicting codes. I found something like this in my code <<<<<<<< But solved it.
I am working on php script which downloads and reads csv file and imports things to database. But I have a problem: when this script is working for a long time, I will get Error 500 - Internal Server Error. I don't know why, but server have set execution time on 90 sec, but my script is working longer time (about 6 minutes) and then I get this error.
When I got execution time error it's ok, because I can catch it with register_shutdown_function() and make another instance with cUrl, but this error is uncatchable for me.
Have anyone any clue how to catch it or make execution time error working ?
I tried set_time_limit(), but it's not working too, because server is in safe mode. And it's web hosting, so I can't change php.ini or something like this.
Thanks for any answer
I came across an issue today, that my PHP script would send a server error 500 upon finishing (on apache). The code was something like:
//many stuff here that work
echo "It reached here";
exit;
and I was always reaching the point before the exit; command. Doing a google search, I came across this post, which suggested turning on display_errors. I did it and the 500 error went away.
So I wanted to ask, does anyone have an explanation on why this happens? This SO post describes a similar case, but there are no explanations.
As always, thanks in advance
It's pretty likely you get a 500 status code as well, but because PHP echoes something to the browser apache won't jump in and display it's standard status 500 error page.
You would need to verify the actual status code to verify that you won't still get a 500 error.
In case of a fatal error, PHP normally sends a 500 status code. As often the process has failed at that time (hence causing the fatal) and sometime no output is generated since then, the webserver jumps in and gives the user the standard 500-internal-server-error-page.
It appears that the code generated a parse error inside an eval() function in a loop. This kind of error does not break code execution but does produce a 500 error
I am using the Codeigniter framework in a project - I have a tool which reads an array and sends out over 10,000 emails using the SwiftMailer Email framework.
One form which I have once submitted is supposed to send out each individual email, however it doesnt sent out all of them as after a period of time I get the following error:
404 Page Not FoundThe page you requested was not found. - 500.shtml
The page itself doesnt actually redirect anywhere else so cannot understand why it would be saying this - anyone have any ideas?
Thanks
It looks like you're actually ending up with a 500 error, but when CI tries to display the custom error page for a 500 error (500.shtml), it can't find it, and so throws a 404 instead. Check your logs for the cause of the 500 error.
It'll be a custom error page, probably set up on the web server itself. If it's an Apache server, check the httpd config and remove any ErrorDocument directives you don't want so you can see the actual error.
As Tom said, if this is happening after a significant delay, you're likely getting a timeout. The length of timeouts can be increased from the PHP end using set_time_limit() or the php.ini setting max_execution_time. However in general if you have a long-running task it is much better to run it in a background process than try to shoehorn it into an HTTP request.