PHPMailer page takes a number of seconds to complete before going to success page. Is there a way to let the user know that it may take a few seconds to "send the mail"?

$mail = new PHPMailer();

$mail->IsSMTP();                                    
$mail->Host = "localhost";
$mail->SMTPAuth = true;
$mail->Username = $user;
$mail->Password = "$password;
$mail->From = $from;
$mail->AddAddress($uemail);
$mail->Subject = $mailsub;
$mail->Body    = $mailmsg;

$mail->Send()

header('location: genmsg.php?tp=confirm&email='.$uemail);

1 Answers

0
Community On

I found a solution!! Basically, on submit, I use a JS function to hide the form and show a previously hidden div asking the user to wait while the request is being submitted.

Added this code the the JS FormValidation function:

document.getElementById('mailform').style.display  = "none"
document.getElementById('mailing').style.display = "block"

When the PHPmailer finishes executing, the user is the redirected to the success page.

( The PHPmailer does take about 3 seconds to execute and then redirect on my server)

Worked perfectly!!!