Verify that the email has already been sent

1

I have the following functionality in my PHP code.

    // Envia o e-mail
    $enviado = $mail->Send();

    // Limpa os destinatários e os anexos
    $mail->ClearAllRecipients();
    $mail->ClearAttachments();


    if( $enviado ){
        return true;

    } else {
        return false;
    }   

Once you've submitted the Submit on the page, trigger an email using the above functionality, however if I give F5, another email is sent. I would like to know if even I updating the page (F5) I can only send an email?

Thank you.

    
asked by anonymous 18.08.2015 / 22:17

2 answers

1
  if( $enviado ){
      echo "<script>alert('E-mail enviado com sucesso!')</script>";
      header("Location: index.php");

        } else {
        echo "<script>alert('E-mail não foi enviado')</script>";
            header("Location: index.php");
        }  
    
19.08.2015 / 00:27
0

Try to create a $_SESSION when sending the email, making it possible to send another email only after the visitor reopens the browser or you clear the sessions.

More information about SESSIONS: link

I hope you have helped. : D

    
21.09.2015 / 06:06