2 Replies - 4158 Views - Last Post: 19 September 2012 - 06:13 AM Rate Topic: -----

#1 hwoarang  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 19-May 12

SMTP Error: Could not connect to SMTP host.

Posted 22 May 2012 - 02:40 AM

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>";
                    }



can some one check if my host is right?
2nd question do i need to change my gamil setting if yes, than what are they?

Is This A Good Question/Topic? 0
  • +

Replies To: SMTP Error: Could not connect to SMTP host.

#2 kojima100  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 66
  • Joined: 10-November 10

Re: SMTP Error: Could not connect to SMTP host.

Posted 22 May 2012 - 12:17 PM

You have to enable POP for your account.
Go here: https://mail.google....tings/fwdandpop , and check "Enable POP for all Mail"
Was This Post Helpful? 0
  • +
  • -

#3 kamkoder  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-January 12

Re: SMTP Error: Could not connect to SMTP host.

Posted 19 September 2012 - 06:13 AM

$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1