While sending mail from server i am getting the following error.
Warning: mail() [function.mail]: SMTP server response: 550 Requested action not taken: mailbox unavailable or not local in C:\Inetpub\vhosts\xxx\signup_success.php on line 70 Email-id that you have registered is not valid.
This is because of wrong Email-id / server settings. My problem is , i want to hide this error from user’s view. How to hide this error mgs .
If this is just for testing purposes, just adding the @ would work. For a production script, you may want to add something more…
if (@mail("", "", "")) {
# email has been sent, continue on.
} else {
# mail() has generated an error, instead of killing the
# remainder of the script, here you can add a custom
# alert that wont break your page with the generated
# error.
echo "There was an error sending your email.";
}
I am developing one shopping site. In signup page , final page i want to send mail conformation to my users. So, here i am getting errors. if the user type wrong mail Id , the above error is displaying. I want hide it and echo “Error”;
I don’t understand your mail Id thing.
you said above it’s “server settings”
now you’re talking of user input but I can’t see any email id processing in the code.
ini_set(“log_errors”, 1); will put all error messages into default webserver’s error log, so, you can watch it there and take proper actions, while user won’t see anything.
if you put @ to gag error message, you won’t see it if some other error occurred
Since you are wanting to output “Error” on a mail() error, you will need to do it this way
if (@mail("", "", "")) {
# email has been sent, continue on.
} else {
# mail() has generated an error, instead of killing the
# remainder of the script, here you can add a custom
# alert that wont break your page with the generated
# error.
echo "There was an error sending your email.";
}
The ini_set() function sets configuration options found in your php.ini file. All that the ini_set() would do in this application would suppress the native PHP errors from generating. Running the if/else statement will check if mail() was successful, and if not, display the error message YOU want.
Yes, and this will suppress the “Warning: mail() [function.mail]: SMTP server response: 550 Requested action not taken: mailbox unavailable or not local in C:\Inetpub\vhosts\xxx\signup_success.php on line 70 Email-id that you have registered is not valid.” until you have this on a server that will send the message.
I would advise strongly against using @ for error suppression. It is the equivalent of brushing the errors under a rug and ignoring them, rather than solving the issue that caused the error in the first place.
Leave errors on for your local development machine, turn them off and log them for the production environment to catch ones you missed otherwise.