title: PHPMailer - SMTP Error: Could not connect to SMTP host
body: <p>I'm trying to send email using PHPMailer. When I tried sending the email from gmail account, it works perfectly fine. However, I would like to send the email from my own SMTP, but there seems to be an error. What could be the problem? Please help me. Thank you.</p>
  
  <p><strong>Using smtp.gmail.com :</strong> </p>
  
  <pre><code>$mail-&gt;SMTPDebug = 3;
  $mail-&gt;isSMTP();                                      
  $mail-&gt;Host = 'smtp.gmail.com';                 
  $mail-&gt;SMTPAuth = true;                               
  $mail-&gt;Username = 'myemail@gmail.com';                 
  $mail-&gt;Password = 'password';                               
  $mail-&gt;SMTPSecure = 'tls';                           
  $mail-&gt;Port = 587; 
  </code></pre>
  
  <p><strong>Using mail.distech.com.my :</strong></p>
  
  <pre><code>require 'PHPMailerAutoload.php';
  
  $mail = new PHPMailer;
  
  $mail-&gt;SMTPDebug = 3;
  $mail-&gt;isSMTP();                                      
  $mail-&gt;Host = 'mail.distech.com.my';                    
  $mail-&gt;SMTPAuth = true;                               
  $mail-&gt;Username = 'myemail@distech.com.my';                 
  $mail-&gt;Password = 'password';                           
  $mail-&gt;SMTPSecure = 'tls';                            
  $mail-&gt;Port = 587; 
  
  $mail-&gt;From = 'myemail@distech.com.my';
  $mail-&gt;addAddress('amalina@distech.com.my');     
  $mail-&gt;Subject = 'Test';
  $mail-&gt;Body    = 'Test message';
  
  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><strong>Error using mail.distech.com.my</strong>  </p>
  
  <pre><code>2015-06-23 06:58:45 Connection: opening to mail.distech.com.my:587, timeout=300, options=array ( ) 
  2015-06-23 06:58:45 Connection: opened 
  2015-06-23 06:58:45 SERVER -&gt; CLIENT: 220-server.firstonline-server16.com ESMTP Exim 4.85 #2 Tue, 23 Jun 2015 14:58:45 +0800 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. 
  2015-06-23 06:58:45 CLIENT -&gt; SERVER: EHLO 192.168.1.20 
  2015-06-23 06:58:46 SERVER -&gt; CLIENT: 250-server.firstonline-server16.com Hello 192.168.1.20 [115.135.120.220] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP 
  2015-06-23 06:58:46 CLIENT -&gt; SERVER: STARTTLS 
  2015-06-23 06:58:46 SERVER -&gt; CLIENT: 220 TLS go ahead 
  Warning: stream_socket_enable_crypto() [function.stream-socket-enable-crypto]: SSL: The operation completed successfully. in C:\xampp\htdocs\ehars\phpmailer\class.smtp.php on line 344
  2015-06-23 06:58:46 SMTP Error: Could not connect to SMTP host. 
  2015-06-23 06:58:46 CLIENT -&gt; SERVER: QUIT 
  Notice: fwrite() [function.fwrite]: send of 6 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host. in C:\xampp\htdocs\ehars\phpmailer\class.smtp.php on line 937
  2015-06-23 06:58:46 SERVER -&gt; CLIENT: 
  2015-06-23 06:58:46 SMTP ERROR: QUIT command failed: 
  2015-06-23 06:58:46 Connection: closed 2015-06-23 06:58:46  SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
  </code></pre>
  
  <p><strong>UPDATE :</strong> </p>
  
  <p>Checked my phpinfo () and the ssl has been enabled.</p>
  
  <p><img src="https://i.stack.imgur.com/iLISG.png" alt="enter image description here"></p>