I am using the PHPMailer for mail, when the site run on localhost mails are successfully sent but after uploading on webserver(freehosting.com) it shows the error and mails are not going ,i checked the path of all files all are proper ,i show the used code, how can i solve it?
**ERROR : ****Connection: opening to smtp.gmail.com:587, timeout=300, options=array ( ) 2016-04-18 11:09:39 SMTP ERROR: Failed to connect to server: Cannot assign requested address (99) 2016-04-18 11:09:39 SMTP connect() failed.******
if ($Flag==true)
`{
require("../../PHPMailer-master/PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = "abc@gmail.com";
$mail->Password = "pass";
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$recev = $to;
$mail->AddAddress($recev'); //by user
$mail->isHTML(true);
$mail->Subject = $subject ; //yby user
$mail->Body =$header; //by user
$mail->WordWrap = 200;
if(!$mail->Send()) {
echo 'Message was not sent!.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo //Fill in the document.location thing'
<script type="text/javascript">
if(confirm("Your mail has been sent"))
document.location = "/";
</script>';
}
}
else
{
echo $msg;
}
?>