How to execute a function until it succeeds?
- by Starx
I am writing a function to send a mail to specific user?
What I am trying to do is, if error occurs I want to keep on sending the mail until the mail is sent.
function sendmail() {
$name = mysql_escape_string($name);
$email = mysql_escape_string($email);
$phone = mysql_escape_string($phone);
$content = nl2br(mysql_escape_string($content));
$subject = "mail from ".$name." (".$email.", Ph: ".$phone.")";
$mail = @mail($feedback,$subject,$content,$headers);
if($mail) { echo "Your mailis send"; }
else { echo "We are sorry for the inconvienience, but we could not send your mailnow."; }
}
the above function displays error message but instead of giving the error, I want to try to send the mail until the mail is finally sent.