title: PHPMailer_v5.1- SMTP Error: Could not authenticate
body: <p>I have the below code and I am getting the following error:</p>
  
  <p>I am using the version PHPMailer_v5.1. I tried another version but it did not work. <br>Any Ideas?    </p>
  
  <blockquote>
    <p>SMTP Error: Could not authenticate</p>
  </blockquote>
  
  <pre><code>$mail = new PHPMailer(false); // the true param means it will throw exceptions on errors, which we need to catch
  $mail-&gt;IsSMTP(); // telling the class to use SMTP
  $mail-&gt;Mailer = "smtp";
  $mail-&gt;SMTPSecure = "ssl"; 
  $mail-&gt;Host       = "smtp.easyname.eu"; // SMTP server
  $mail-&gt;Port       = 465; 
  $mail-&gt;SMTPDebug  = 0;                     // enables SMTP debug information (for testing)
  $mail-&gt;SMTPAuth   = true;                  // enable SMTP authentication
  $mail-&gt;Username   = "info@mydomain.net"; // SMTP account username
  $mail-&gt;Password   = "*****";            // SMTP account password
  $mail-&gt;AddReplyTo("$fromEmail", "$from");
  $mail-&gt;AddAddress("$toEmail", "$toName");
  $mail-&gt;SetFrom("$fromEmail", "$from");
  $mail-&gt;Subject = "New enquiry to example (SUBJECT:'$subject')";
  $mail-&gt;AltBody = "$message"; // optional - MsgHTML will create an alternate automatically
  $mail-&gt;MsgHTML("$message");
  $mail-&gt;Send();
  if($settings['cc_sender'])
  {
      $mail = new PHPMailer(false); // the true param means it will throw exceptions on errors, which we need to catch
      $mail-&gt;IsSMTP(); // telling the class to use SMTP
      $mail-&gt;Mailer = "smtp";
      $mail-&gt;SMTPSecure = "ssl";
      $mail-&gt;Host       = "smtp.easyname.eu"; // SMTP server
      $mail-&gt;Port       = 465;
      $mail-&gt;SMTPDebug  = 0;                     // enables SMTP debug information (for testing)
      $mail-&gt;SMTPAuth   = true;                  // enable SMTP authentication
      $mail-&gt;Username   = "info@mydomain.net"; // SMTP account username
      $mail-&gt;Password   = "******";           // SMTP account password
      $mail-&gt;AddReplyTo("no-reply@mydaomain.net", "example Website");
      $mail-&gt;AddAddress("$fromEmail", "example Enquiry");
      $mail-&gt;SetFrom("info@mydomain.net", "example Enquiry");
      $mail-&gt;Subject = "Your enquiry from example (SUBJECT:'$subject')";
      $mail-&gt;AltBody = "$message"; // optional - MsgHTML will create an alternate automatically
      $mail-&gt;MsgHTML("$message");
      $mail-&gt;Send();
  }
  </code></pre>