1

Trying to send a simple contact form on my website, however, the page is just hanging when it gets to $mail->send();

this is my code...

    require('class.phpmailer.php');
    require('class.smtp.php');

    $mail = new PHPMailer;

    $mail->isSMTP();
    $mail->Host = 'gator4099.hostgator.com';
    $mail->SMTPAuth = true;
    $mail->Username = 'MY USER NAME';
    $mail->Password = 'MY PASSWORD';
    $mail->Port = 465;

    $mail->setFrom('info@emailaddress.com', 'Mailer');
    $mail->isHTML(true);

    $name = $_POST['name'];
    $email = $_POST['email'];
    $number = $_POST['number'];
    $message = $_POST['message'];

    $mail->SMTPAuth   = true;
    $mail->AddAddress('myname@domain.com', "MY NAME");
    $mail->Subject = 'Website Contact Form';
    $mail->Body    = 'name = '.$name.'<br/> email = '.$email.' <br/>  number = '.$number.' <br/> message = '.$message.'<br/><br/><br/> :) ';


    if(!$mail->send()) {
        echo 'Message could not be sent.';
        $mailSent = 0;
    } else {
        echo 'message sent';
        $mailSent = 1;
    }

in the above, I had removed my username, password and email addresses for obvious reasons. But they are 100% correct in my code.

If I echo anything out before $mail->send() it displays, however, anything after will not display and the browser just has the loading symbol constantly spinning.

Any ideas?

virepo
  • 320
  • 5
  • 22
  • Possible duplicate of https://stackoverflow.com/questions/15692354/phpmailer-hangs-on-send or https://stackoverflow.com/questions/35945391/phpmailer-hangs – Peter Featherstone Jul 24 '17 at 19:37
  • From a previous post, they just changed the port to 465, but I see that's what yours is already set to. That was a while ago, so maybe change it to another port number? I've heard hostgator has alternative, unpublished open ports (993/587 comes to mind). https://stackoverflow.com/questions/15692354/phpmailer-hangs-on-send Good luck! – Aaron Belchamber Jul 24 '17 at 19:38
  • @PeterFeatherstone You marked this as a possible duplicate of two other questions with unsatisfactory answers. – Altimus Prime Jul 30 '20 at 01:27

0 Answers0