PHP prevent an enamel loops in mail autoresponders (Loop)

A typical problem with automatic e-mail replies (Auto Respondern) is, that can lead to an endless loop, automatically when responding to emails and the recipient, an automatic e-mail as. an absence leave e-mail sent. The phenomenon is called Email Loop.

Email the loop can only be prevented by a fixed limit on messages to the same recipient. One should e.g.: set, that day, only one e-mail will be sent to an addressee check by auto responder and do this with a database.

Query the database for all emails, not older than a day, and have already been answered,might look like:

 $sql = "SELECT COUNT(response_sent)
         FROM autoresponder
         WHERE email='{$email}' AND date_received > TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 day)) AND response_sent=1";

An auto-responder in PHP consists of 3 Share:

  1. the Retrieve emails from the mailbox
  2. being stored in the database of e-mail data
  3. the responses to e-mails

If you want to uncover an auto-responder is not the same as those, because immediately sent a reply, wanted to set up a cron job, the determined randomly with a certain probability, whether an email is answered or not.

e.g.. with probability 10%:

if(rand(0, 1) <= 0.1)