As part of the registration process on a website, I have added mail confirmation. But for some reason, the mail function throws an Internal server error in there.
The strange thing is that if I create a test script, with the exact same email (all the same parameters) it works fine, and sends the email.
The mail is sent from a function in a Class, in case that helps. I didn’t post the code because it isn’t really relevant, even if I try mail('email@email.com','subject','email');
it fails with the 500 error!
The server error logs don’t show anything at all, anyone knows what may cause such a problem?
Technology:
The server is running php through mod_fastcgi
, although this problem also happens if I switch to mod_suphp
.
Updates:
UPDATE:
I’ll try to explain this better, the mail function works perfectly if called from another file, with the same parameters. The problem here is something that combined with the mail function causes an error 500. The rest of the file where it’s called is fine too, if I comment the mail function everything works. The way it gets called is an AJAX request to a file that calls a function where the mail is sent (Just in case this helps)
UPDATE 2:
In response to answers so far, here is more information I did not share previously:
OS: CentOS release 5.8
When I say error 500, I mean that the server returns only an HTTP 500 status code.
The server does not show anything in any error log
The most important thing is that if I create a file called test.php, with only mail('address@domain.com','Subject','Message')
, it works just fine. When called from this other file, 500 status code returned.
What I am asking is if anyone knows, probably from experience, what could be causing this.
UPDATE 3:
Someone had the same problem yesterday: PHP's mail() function causes a 500 Internal Server Error only after a certain point in the code
UPDATE 4:
After some testing, I have discovered that the 500 stats code is only returned when the script is called via AJAX. If I create a file called test.php, and I simply place the mail function and test it, it works. Calling it via AJAX doesn’t, any ideas?