php - How to execute a function until it succeeds? -


Am I writing a function to send mail to a specific user?

What am I trying to do, if there is an error, I want to continue sending 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)); $ Theme = "mail" to "$." ("$ Email.", PH: ". $ Phone."); $ Mail = @mail ($ response, $ theme, $ content, $ header); if ($ mail) {resonant "send your mail" ;} Else {echo "We apologize for the inconvenience, but we could not send your mail on.";}} The above work displays the error message but instead of giving an error, I I want to try sending mail until the mail is sent in the end 

for error handling Design:

Why If the page can not be sent? Daemon stopped, the user entered the malformed data, the connection was lost, the disk could write, the database was down for the menu, etc. What do you do with the user request to the user Want to? I recommend setting up a queue on the failure to try again later. There are so many good queue systems that try the cron if you have that Notify the administrator tries it does not hang on client request). Log and if there is some error conditions.

It is designed for a management / infrastructure team, but you have some good tooling and error and exception management. People who receive your code will thank you.

I am studying practical programmers and I have to be highly recommended to handle this question specifically. It sets a standard in the way you think about dealing with the error / exception, and has definitely approved fog for me, which is an error, an exception, a claim condition (or impossible situation) Vs. Practical distraction in special chapter 4:

"When all people really come out from you, then monsoon is just good thinking" -Velie Allen


Comments