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?