title: Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting in my code
body: <p>I am new in Php I have to send resume using phpmailer. I found error as "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>". Plz need change in code. I am using phpmailer in my code. It works when i am doing first time but now this code will gives error.</p>
  
  <pre><code>&lt;?php 
  
  include('header.php');
  require 'PHPMailerAutoload.php';
  $message='';
  
  if(isset($_POST["submit"]))
  {
     $path='upload/'.$_FILES["resume"]["name"];
     move_uploaded_file($_FILES["resume"]["tmp_name"], $path);
  
     $mail = new PHPMailer;
  
  $mail-&gt;SMTPDebug = 0;                               // Enable verbose debug output
  
  $mail-&gt;isSMTP();                                      // mailer to use SMTP
  $mail-&gt;Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
  $mail-&gt;SMTPAuth = true;                               // Enable SMTP authentication
  $mail-&gt;Username = 'xyz01@gmail.com';                 // SMTP username
  $mail-&gt;Password = 'mypasswordgoeshere';                           // SMTP password
  $mail-&gt;SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
  $mail-&gt;Port = 465;                                    // TCP port to connect to
  
  $mail-&gt;From=$_POST['email'];
  $mail-&gt;FromName=$_POST['name'];
  $mail-&gt;setFrom($_POST['email']);
  $mail-&gt;addAddress('xyz01@gmail.com'); 
  
  $mail-&gt;AddCC($_POST['name'],$_POST['email']);
  
  $mail-&gt;WordWrap=50;
  
  $mail-&gt;AddAttachment($path);
  
  $mail-&gt;Subject='application for job';
      // Add a recipient
                // Name is optional
  $mail-&gt;addReplyTo($_POST['email']);
  
  $mail-&gt;isHTML(true);                                  // Set email format to HTML
  
  //$mail-&gt;Subject = $_POST['subject'];
  $mail-&gt;Body    = $_POST['message'];
  $mail-&gt;AltBody = $_POST['message'];
  
  
  
  if(!$mail-&gt;send()) {
      echo '&lt;script&gt;alert("Message could not be sent.")&lt;/script&gt;';
      echo 'Mailer Error: ' . $mail-&gt;ErrorInfo;
  } else {
      echo '&lt;script&gt;alert("Message has been sent");
  
          window.location.href="career.php";
      &lt;/script&gt;';
  
  }
  
  
  }
  
  ?&gt;
  </code></pre>