title: Mailer Error: SMTP connect() failed in php mailer( https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting)
body: <p>Here is code for sending email from localhost after i referred a lot from online.</p>
  <p>html form:</p>
  <pre><code>&lt;form method=&quot;post&quot; action=&quot;email.php&quot;&gt;
    Email: &lt;input name=&quot;email&quot; id=&quot;email&quot; type=&quot;text&quot; /&gt;&lt;br /&gt;
  
    Message:&lt;br /&gt;
    &lt;textarea name=&quot;message&quot; id=&quot;message&quot; rows=&quot;15&quot; cols=&quot;40&quot;&gt;&lt;/textarea&gt;&lt;br /&gt;
  
    &lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
  &lt;/form&gt;
  </code></pre>
  <p>email.php:</p>
  <pre><code>&lt;?php
  
  // $email and $message are the data that is being
  // posted to this page from our html contact form
  $email = $_REQUEST['email'] ;
  $message = $_REQUEST['message'] ;
  
  require_once('class.phpmailer.php');
  require 'PHPMailerAutoload.php';
  require 'class.smtp.php';
  
  $mail = new PHPMailer();
  $body='hellooooo';
  $mail-&gt;IsSMTP();
  
  $mail-&gt;Host = &quot;ssl://smtp.gmail.com&quot;; // specify main and backup server
  
  $mail-&gt;SMTPAuth = true; // turn on SMTP authentication
  
  $mail-&gt;Username = &quot;xxxx@gmail.com&quot;; // SMTP username
  $mail-&gt;Password = &quot;zzz&quot;; // SMTP password
  $mailer-&gt;SMTPSecure = 'ssl';
  $mailer-&gt;Port = 465;//587;
  $mail-&gt;AddAddress(&quot;xxx&quot;, &quot;xx&quot;);
  $mail-&gt;SetFrom('xxx@gmail.com','xxxx');
  $mail-&gt;WordWrap = 50;
  
  $mail-&gt;IsHTML(true);
  
  $mail-&gt;Subject = &quot;You have received feedback from your website!&quot;;
  
  $mail-&gt;MsgHTML($body);
  
  if(!$mail-&gt;Send())
  {
  echo &quot;Message could not be sent. &lt;p&gt;&quot;;
  echo &quot;Mailer Error: &quot; . $mail-&gt;ErrorInfo;
  exit;
  }
  
  echo &quot;Message has been sent&quot;;
  ?&gt;
  </code></pre>
  <p>so when i run my code it shows error like this,</p>
  <blockquote>
  <p>Message could not be sent.</p>
  <p>Mailer Error: SMTP connect() failed. <a href="https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting" rel="nofollow noreferrer">https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting</a></p>
  </blockquote>
  <p>And i removed semicolon in this line <code>;extension=php_openssl.dll</code> from the following files, and restart the xampp.</p>
  <pre><code>c/xampp/apache/bin/php.ini and c/xampp/php/php.ini
  </code></pre>
  <p>still stays same error..</p>
  <p><strong>Note:</strong> I m new to php, but i want to know particular this one and fix the problem. and I referred similar questions in stack, but it didn't help me,</p>
  <p>Can anybody help me to fix this?</p>
  <p>Thanks,</p>