title: Unable to send mail with PHPMailer and Mailtrap
body: <p>I am trying to send a test e-mail to a mailtrap.io inbox,  but I keep getting these errors when I turn the debugging on. Previously I was getting a Username command failed until I added AuthType = Login.</p>
  
  <pre><code>2017-08-01 22:34:46 SERVER -&gt; CLIENT: 220 mailtrap.io ESMTP ready 
  2017-08-01 22:34:46 CLIENT -&gt; SERVER: EHLO localhost 
  2017-08-01 22:34:46 SERVER -&gt; CLIENT: 250-mailtrap.io 250-SIZE 5242880 250-PIPELINING 250-ENHANCEDSTATUSCODES 250-8BITMIME 250-DSN 250-AUTH PLAIN LOGIN CRAM-MD5 250 STARTTLS 
  2017-08-01 22:34:46 CLIENT -&gt; SERVER: STARTTLS 
  2017-08-01 22:34:46 SERVER -&gt; CLIENT: 220 2.0.0 Start TLS 
  2017-08-01 22:34:47 CLIENT -&gt; SERVER: EHLO localhost 
  2017-08-01 22:34:47 SERVER -&gt; CLIENT: 250-mailtrap.io 250-SIZE 5242880 250-PIPELINING 250-ENHANCEDSTATUSCODES 250-8BITMIME 250-DSN 250 AUTH PLAIN LOGIN CRAM-MD5 
  2017-08-01 22:34:47 CLIENT -&gt; SERVER: AUTH LOGIN 
  2017-08-01 22:34:47 SERVER -&gt; CLIENT: 334 xxxx
  2017-08-01 22:34:47 CLIENT -&gt; SERVER: xxxxxxxxxxx= 
  2017-08-01 22:34:47 SERVER -&gt; CLIENT: 334 xxxxxxxxxxxx 
  2017-08-01 22:34:47 CLIENT -&gt; SERVER: 
  2017-08-01 22:34:50 SERVER -&gt; CLIENT: 535 5.7.0 Invalid login or password 2017-08-01 22:34:50 SMTP ERROR: Password command failed: 535 5.7.0 Invalid login or password 
  2017-08-01 22:34:50 SMTP Error: Could not authenticate. 
  2017-08-01 22:34:50 CLIENT -&gt; SERVER: QUIT 
  2017-08-01 22:34:51 SERVER -&gt; CLIENT: 221 2.0.0 Bye 
  2017-08-01 22:34:51 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
  </code></pre>
  
  <p>Here is my code on the page that tries to send the e-mail. The credentials are stored in the Config class, and I have verified several times that the username and password match the ones provided by the mailtrap inbox. Currently the port is set to 465. I have tried 2525 as well to the same results. Port 25 only makes the application time out.</p>
  
  <pre><code>if(isMethod('post')) {
      if (isset($_POST['email'])) {
          /*********************
           *configure PHPMailer*
           *********************/
          $mail = new PHPMailer();
          $mail-&gt;AuthType = 'LOGIN';
          $mail-&gt;SMTPDebug = 2;
          $mail-&gt;isSMTP();
          $mail-&gt;Host = Config::SMTP_HOST;
          $mail-&gt;SMTPAuth = true;
          $mail-&gt;Username = Config::SMTP_USER;
          $mail-&gt;Passowrd = Config::SMTP_PASSWORD;
          $mail-&gt;SMTPSecure = 'tls';
          $mail-&gt;Port = Config::SMTP_PORT;
          $mail-&gt;isHTML(true);
          $mail-&gt;setFrom('myemail@gmail.com', 'My Name');
          if (!getEmailDb()) {
              echo (displayMessage("E-Mail does not exist.", "warning"));
          }
          else {
              $email = getEmailDb();
              $token = bin2hex(openssl_random_pseudo_bytes(50));
              $mail-&gt;addAddress($email);
              $mail-&gt;Subject = 'This is a test email.';
              $mail-&gt;Body = 'Email body';
  
              if($mail-&gt;send()) {
                  echo (displayMessage("E-Mail sent. It should show up in your inbox pretty soon.", "success"));
              }
              else {
                  echo (displayMessage("Could not send E-Mail to ".$email, "warning"));
              }
          }
      }
  </code></pre>
  
  <p>}</p>