Re: mail() error handling
| From: | Stut | Date: | Thu, 05 Jun 2008 09:45:05 +0000 |
| Subject: | Re: mail() error handling | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-275051@lists.php.net to get a copy of this message | ||
On 5 Jun 2008, at 09:48, Henrik Johansson wrote:
I have a piece of code that uses mail() to, well, send mail. It works, but not the error handling which is as follows: <snip> $send = @mail( $to, $subject, $body, $headers ); if($send) {header( "Location: http://somewhere/thankyou.html" );} else {print "Oops, couldn't deliver the message, please try again soon."; } I checked, and it always returns 1, even though I tried a user@server that doesn't exist! Anyone got a clue what I've done wrong?The mail function will succeed if it completes it's task, which on unix-based systems is simply to pass the message on to sendmail. So, in your case I'd say sendmail is accepting the message so mail is quite correct in thinking it succeeded. -Stut -- http://stut.net/