title: SMTP connect() failed phpmailer
body: <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  require 'PHPMailer-master/PHPMailerAutoload.php';
  $mail = new PHPMailer();
  
  $mail-&gt;SMTPDebug = 1;                               // Enable verbose debug output
  
  $mail-&gt;isSMTP();                                      // Set mailer to use SMTP
  $mail-&gt;Host = 'smtp.mail.yahoo.com';  // Specify main and backup SMTP servers
  $mail-&gt;SMTPSecure = &quot;ssl&quot;;
  $mail-&gt;SMTPAuth = true;                               // Enable SMTP authentication
  $mail-&gt;Username = 'myemail';                 // SMTP username
  $mail-&gt;Password = 'mypass';                           // SMTP password
  //  $mail-&gt;SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  $mail-&gt;Port = 465;                                    // TCP port to connect to
  
  $mail-&gt;From = 'myemail@yahoo.com';
  $mail-&gt;FromName = 'abc';
  $mail-&gt;addAddress('abc@abc.com');               // Name is optional
  
  
  //$mail-&gt;isHTML(true);                                  // Set email format to HTML
  
  $mail-&gt;Subject = 'Here is the subject';
  $mail-&gt;Body = 'This is the HTML message body &lt;b&gt;in bold!&lt;/b&gt;';
  //  $mail-&gt;AltBody = 'This is the body in plain text for non-HTML mail clients';
  
  if (! $mail-&gt;send()) {
      echo 'Message could not be sent.';
      echo 'Mailer Error: ' . $mail-&gt;ErrorInfo;
  } else {
      echo 'Message has been sent';
  }
  </code></pre>
  <p>I have tried gmail also but it keeps giving me error SMTP connect() failed.</p>
  <p>here is the error</p>
  <pre><code>    2015-05-16 07:28:09    CLIENT -&gt; SERVER: EHLO localhost
  2015-05-16 07:28:09    CLIENT -&gt; SERVER: AUTH LOGIN
  2015-05-16 07:28:10    CLIENT -&gt; SERVER: bWF0ZWVuX3VsX2hhcUB5YWhvby5jb20=
  2015-05-16 07:28:10    CLIENT -&gt; SERVER: c2hhaGlkYWZyaWRpMW1hcmNoMTk5MQ==
  2015-05-16 07:28:11    SMTP ERROR: Password command failed: 501 Syntax error in arguments
  2015-05-16 07:28:11    SMTP Error: Could not authenticate.
  2015-05-16 07:28:11    CLIENT -&gt; SERVER: QUIT
  2015-05-16 07:28:11    SMTP connect() failed.
  
  https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
  
  Message could not be sent.
  
  Mailer Error: SMTP connect() failed. 
  </code></pre>