0

i'm having difficulty setting up phpmailer on my local web server and would appreciate any help

i am running xamppp 1.7.4 and php 5.3.5 - i keep receiving the following error message whenever trying to send mail

SMTP Error: Could not connect to SMTP host.

here is the code i am using right now

require("resources/phpmailer/class.phpmailer.php");
    //send the email with an email containing the activation link to the supplied email address

   $mailer = new PHPMailer();
   $mailer->IsSMTP();  // telling the class to use SMTP
   $mailer->Mailer = "smtp";
   $mailer->Host = "ssl://smtp.gmail.com";
   $mailer->Port = 587;
   $mailer->SMTPAuth = true; // turn on SMTP authentication
   $mailer->Username = $email_kite;
   $mailer->Password = $emailpass_kite;
   $mailer->From = $email_kite;
   $mailer->FromName = 'Kite';
   $mailer->Body = 'Testing';
   $mailer->Subject = 'Get started with Kite';
   $mailer->AddAddress($email);
   if(!$mailer->Send())
   {
       // message not sent
  echo '<p class="c7">Unfortunately the <b>activation</b> email could not be sent and user registration has failed. Please go <a href="register.php">back</a> and try again.</p>';
      echo '<br><img src="resources/img/spacer.gif" alt="" width="1" height="10">';
  include_once ("resources/php/footer.php");
  exit;
   }
   else
   {
       // message sent
       "Email sent successfully!";
   }
    }

thanks!

methuselah
  • 12,766
  • 47
  • 165
  • 315
  • Duplicate of http://stackoverflow.com/questions/6168882/resolved-phpmailer-to-use-gmail-as-smtp-server-could-not-connect-to-smtp-host ? – Nemo Jun 02 '11 at 06:07
  • 2
    No, I don't think it is. If the dll wasn't being loaded, I don't think it would be generating that message. I really think it's the port. Even if the dll isn't being loaded, that's definitely going to keep it from working. – King Skippus Jun 02 '11 at 18:31

1 Answers1

1

Try using

$mailer->Port = 465;

Port 587 is for TLS, the SSL port is 465.

King Skippus
  • 3,801
  • 1
  • 24
  • 24
  • Instead of falling back to the obsolete and deprecated SSL mechanism, how about making the TLS approach work? $mailer->Port = 587; $mailer->Host = "tls://smtp.gmail.com"; – Synchro Mar 22 '13 at 13:07