开发者

PHP mail() errors: Hide attempted email but still show error

开发者 https://www.devze.com 2023-01-07 12:18 出处:网络
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:

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 - mail@email.com, Password Reset,
You have requested your passw开发者_如何学编程ord 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...)


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消