icekat83 Posted July 24, 2009 Share Posted July 24, 2009 Hey, I'm new to this forum, although not to PHP but I've hit a wall with this. I have form processor page sending a contact mail and need to suppress error messages of my mail() function (using @). However I want to know if there is an error so is there a way I can check for an error manually, so I can decide what happens? The idea is that the user sees a pretty 'sorry there was an error' message instead of the confusing php error message. Does anyone know of a good method? Thanks, Alanna. Link to comment https://forums.phpfreaks.com/topic/167255-solved-mail-function-manual-error-check/ Share on other sites More sharing options...
Bendude14 Posted July 24, 2009 Share Posted July 24, 2009 as the documentation quite clearly says the mail function returns true on success and false on failure. http://au.php.net/manual/en/function.mail.php Link to comment https://forums.phpfreaks.com/topic/167255-solved-mail-function-manual-error-check/#findComment-881856 Share on other sites More sharing options...
icekat83 Posted July 24, 2009 Author Share Posted July 24, 2009 I have a line in my code: @mail($recipient, $subject, $msg, $headers); -- with the @ symbol to stop error messages being printed. However if I put in something like: if(mail()) == false){ echo 'error'; } I get a message saying that '3 parameters are expected'. Link to comment https://forums.phpfreaks.com/topic/167255-solved-mail-function-manual-error-check/#findComment-881971 Share on other sites More sharing options...
icekat83 Posted July 24, 2009 Author Share Posted July 24, 2009 LOL. Brain dead moment. I gave it a variable name and used === instead of ==, now it works. Link to comment https://forums.phpfreaks.com/topic/167255-solved-mail-function-manual-error-check/#findComment-881989 Share on other sites More sharing options...
Bendude14 Posted July 24, 2009 Share Posted July 24, 2009 if statement check for true or false, doing if mail() == false is the same as saying if false == false.. Simply do if( mail() ) { } Link to comment https://forums.phpfreaks.com/topic/167255-solved-mail-function-manual-error-check/#findComment-882122 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.