SMTP Error: Could not connect to SMTP host.
can some one check if i doing this right?
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->Host = " smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl"; //ssl or tls
//$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465; //set smtp port for the gmail
$mail->Username = "test1@gmail.com"; //yourname@yourdomain
$mail->Password = "asdfasdf"; //password
//to
$mail->AddAddress("test2@hotmail.com"); //to:
//subject
$mail->Subject = "tttt";
//html body
$mail->IsHTML(true);
$mail->Body = "HEllow ikhlas";
//from
$mail->From = "test1@gmail.com";
$mail->FromName = "test";
$mail->wordWrap = 50;
//send
if(!$mail->send())
{
$forgot_error .= "Mail error ".$mail->ErrorInfo;
}
else
{
$forgot_error .= "E-mail has be sent to <b>$email_f</b>";
}