Mailer Error: SMTP Error: Could not connect to SMTP host.
Posted: Sat Feb 21, 2009 5:06 am
I m using gmail as mail server but not able to send mail. I m using class.phpmailer.php and class.smtp.php
getting the following error:
Mailer Error: SMTP Error: Could not connect to SMTP host.
getting the following error:
Mailer Error: SMTP Error: Could not connect to SMTP host.
Code: Select all
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Mailer = "smtp";
$mail->Host = "ssl://smtp.gmail.com"; // SMTP server
$mail->Port = 465;
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "username@domain.com"; // SMTP username
$mail->Password = "password"; // SMTP password
$mail->From = $email;
$mail->FromName = $name;
$mail->AddAddress("username@domain.com","Rashmi");
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
mail->Subject = $subject;
$mail->Body = "
<strong>Name : </strong>".$name."<br/>
<strong>Email : </strong>".$email."<br/>
<strong>Mobile Number : </strong>".$mobile."<br/>
<strong>Phone Number : </strong>".$phone."<br/>
<strong>Message : </strong>".$writetous;
$mail->AltBody = "
Name: ".$name."
Email: ".$email."
Mobile Number: ".$mobile."
Phone Number: ".$phone."
Message: ".$writetous;
if(!$mail->Send())
{
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
header('location:thanks.php');
}
else {
$msg= 'Sorry, you have provided an invalid security code';
$_SESSION['msg']=$msg;
header('location:thanks.php');
}
?>