I've currently got set_error_handler()
throwing ErrorException
whenever anything is encountered. Furthermore, I've got error_reporting()
at -1
, so mis-indexing an array throws an exception.
Anyways, that being a cursory overview of my error/reporting environment; the PHP mail()
function is tossing errors on my (Win7) dev machine, during a process intended for a project, 'cause I don't have a mail server installed. I tried prefixing it with @
to shut it up, but it still triggers an error, and hence throws an exception. I could wrap it with try{}
, but I'm curious as to why it won't shut up.
Why won't it shut up?
To reiterate, we can almost remove mail()
from the equation (so far as I can tell); I just want to know why @
wouldn't do it's job under such a circumstance, with mail()
or any function. I just figured mail()
may be special case for some reason.
Thanks to our friend XDebug
:
( ! ) ErrorException: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\dbc_relaunch_2-0-0\mf\handlers\api\mail\send.php on line 16
Alrighty, I've simply gone with:
try{
mail($args);
catch(Exception $exception){
return $failure;
}
return $success;
Rather than:
if(@mail($args)){
return $failure;
}
return $success;
And all is well; I'm browsing the answer @Pheonix linked, but anyone with a short order response as to why this is free to answer.