mail() error checking function

From: Date: Fri, 22 Mar 2002 12:49:13 +0000
Subject: mail() error checking function
Groups: php.general 
Request: Send a blank email to php-general+get-89662@lists.php.net to get a copy of this message
Hello all, I have the bellow script which will be called from the following URL "http://172.24.110.113/sendmail.php?to=0761234567@domain.ch&body=this is a test message". The "to" and "body" field in the URL are variable. The problem I have, there is no error checking in this script, it replays always with "Email has been sent..." even if the the user not exists. It would be nice to have some error checking regarding the SMTP server response like 200 = message sent or 550 = unknown user,.... Is there a way to check this with PHP? (Î'm sure there is...) It would be nice if you cold provide some Code exsample because my programming experiance is not very high. ---------------------------------------------------------------------------- ------------------------------------------------------ <?php echo "<html><body>"; $to = preg_replace("/^0041/", "0", $to); $recipient = $to; $subject = "OneBox, SMS to Email service"; $message .= " \n"; $message .= $body; $message .= " \n"; $message .= " \n"; $message .= " \n"; $message .= "------------------------------------------------------------------; $message .= "body footer\n"; $message .= "------------------------------------------------------------------; $message .= " \n"; #$extra = "From: sms_to_email@domain.ch"; #$extra = "From: SMS to E-Mail Service <sms_to_email@domain.ch>\r\nReturn-Pa; $extra .= "From: SMS to E-Mail <sms_to_email@domain.ch>\n"; $extra .= "X-Sender: <sms_to_email@domain.ch>\n"; $extra .= "X-Mailer: PHP\n"; $extra .= "X-Priority: 3\n"; $extra .= "Return-Path: <sms_to_email@domain.ch>\n"; mail ($recipient, $subject, $message, $extra); echo "Email has been sent..."; echo "</body></html>"; ?> ---------------------------------------------------------------------------- ------------------------------------------------------ Thanks for your support Marc

« previous php.general (#89662) next »