Reputation: 2943
I am working on a 'forgot password' form, currently I am working locally so the mail function will not work but the errors come up like this:
Warning: 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 ... on line 508
Error Sending Email - [email protected], Password Reset,
You have requested your password to be reset. To login, use the username and password below:
Username: admin
Password: azurapura
...
Obviously, if the mail function does not work I wouldn't want someone to see the message/password unless it is through their mail. Is there a way to disable that part of the error from showing or is there a way to customize the error for this function?
I saw a post to create error handlers however, this seems like it only applies to types of errors (warnings...)
Upvotes: 0
Views: 501
Reputation: 34107
I really recommend you have display_errors turned off on your production machine.
mail
returns a boolean value telling if the message was accepted for delivery or not. Use that to detect errors.
Upvotes: 0
Reputation: 101926
Simply prefix the mail
with an email-sign (can't type one here!). This way PHP supresses the error. Futher info: http://php.net/manual/en/language.operators.errorcontrol.php
Upvotes: 1