I am having trouble in sending mail through php mailer, I am easily able to send email on localhost (Wampp) but on live sever I am getting the error:
SMTP Error: Could not connect to SMTP host. failed
<?php
if (isset($_POST['submit'])) {
# code...
$customeremail="*************";
$message=
'Full Name: '.$_POST['name'].'<br />
Subject: '.$_POST['subject'].'<br />
Phone: '.$_POST['phone'].'<br />
Email: '.$_POST['email'].'<br />
Comments: '.$_POST['message'].'
';
require "phpmailer/class.phpmailer.php"; //include phpmailer class
// Instantiate Class
$mail = new PHPMailer();
// Set up SMTP
$mail->IsSMTP(); // Sets up a SMTP connection
$mail->SMTPAuth = true; // Connection with the SMTP does require authorization
$mail->SMTPSecure = "ssl"; // Connect using a TLS connection
$mail->Host = "smtp.gmail.com"; //Gmail SMTP server address
$mail->Port = 465; //Gmail SMTP port
$mail->Encoding = '7bit';
// Authentication
$mail->Username = "******"; // Your full Gmail address
$mail->Password = "******"; // Your Gmail password
// Compose
$mail->From = "*************";
$mail->FromName = "**********";
$mail->Subject = "DRIVER AND CAR DETAILS"; // Subject (which isn't required)
$mail->MsgHTML($message);
// Send To
$mail->AddAddress($customeremail, "Recipient Name"); // Where to send it - Recipient
$result = $mail->Send(); // Send!
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>
I tried creating a php.ini file and putting extension=php_openssl.dll
but its also not working, there are my other websites too, but am getting error in this only, please help me!!