How to limit sending email every 24 hours?

Asked

Viewed 36 times

0

In a way that was done by javascript and saved directly on the client side and not by the server?

     <?php

         // UTF-8
         header('Content-Type: text/html; charset=utf-8');

          date_default_timezone_set('America/Sao_Paulo');
        $date = date('Y-m-d H:i');

        //se nao funcionar remover
        //if (isset($_POST['BTEnvia'])) {

           // from the form
         $nome = $_POST['nome'];
         $email = $_POST['email'];
         $telefone = $_POST['telefone']; 
         $mensagem = $_POST['mensagem'];


         //REMETENTE --> ESTE EMAIL TEM QUE SER VALIDO DO DOMINIO
         //==================================================== 
         $email_remetente = "[email protected]"; // deve ser uma conta de email do seu dominio 
         //====================================================

         //Configurações do email, ajustar conforme necessidade
         //==================================================== 
         //EDIT 10/10 14:15 $email_destinatario = "[email protected]"; // pode ser qualquer email que receberá as mensagens
         $email_reply = "$email"; 
         $email_assunto = "Nova mensagem no formulário"; // Este será o assunto da mensagem
         //====================================================

        // ENVIA e-mail para um determinado e-mail de acordo com a hora do dia
        //======================================================
        $date = new \DateTime();

        $date->setTime(18,00,00);

        $dateNow = new \DateTime();

        //antes de meio dia
        $email_destinatario = '[email protected]'; 

        //Depois de meio dia
        if($dateNow > $date) {
            $email_destinatario = '[email protected]';
        }


               $subject = "Nova mensagem BR";
               $to = '[email protected]';
          //======================================================   


         $email_conteudo = "<b>Nome:</b>: $nome \n"; 
         $email_conteudo .= "<b>Email:</b>  $email \n";
         $email_conteudo .= "<b>Assunto:</b> $telefone \n"; 
         $email_conteudo .= "<b>Mensagem:</b> $mensagem \n"; 



               // send the email

                $email_headers = implode ( "\n",array ( "From: $email_remetente", "Reply-To: $email_reply", "Return-Path: $email_remetente","MIME-Version: 1.0","X-Priority: 3","Content-Type: text/html; charset=UTF-8" ) );


                mail($email_destinatario, $email_assunto, nl2br($email_conteudo), $email_headers); //$body 12-10



        ?>
  • I can’t understand what you want to do.

  • Runs a cron counting if a day has passed and changes the status to not sent again and releases the upload. Of course you need to validate minimum quantity that it can be sending.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.