title: SMTP Error - Can't Connect to Network
body: <p>I've been trying to implement SMTP with PHPMailer for about a week now. I'm revising my old mail() php script and am having difficulty even setting up a live test taken right from the example since I keep receiving the same error. I'm currently running a HostGator dedicated server and my MX record (mail server) is through Office 365/Outlook. For some reason, I keep getting the <code>can't connect to network</code> error as seen in the image below. </p>
  
  <p><a href="https://i.stack.imgur.com/3Qumv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Qumv.png" alt="enter image description here"></a></p>
  
  <p>My code is below which I took from the github SMTP example. I originally used port 587 with 'tls' authentication but this did not work and after speaking with Microsoft they suggested I do port 25 with no authentication. Still the same error. Can anyone explain to me what i'm doing wrong or suggest a better route of approach? Thanks!</p>
  
  <p>Code:</p>
  
  <pre><code> &lt;?
   require(dirname(__FILE__)."/PHPMailerAutoload.php");
   $mail = new PHPMailer;
   $mail-&gt;isSMTP();
   $mail-&gt;SMTPDebug = 2;
   $mail-&gt;Debugoutput = 'html';
   $mail-&gt;Host = 'smtp.office365.com';
   $mail-&gt;Port = 25;
   $mail-&gt;SMTPSecure = 'tls';
   $mail-&gt;SMTPAuth = true;
   $mail-&gt;Username = "jason@***.com";
   $mail-&gt;Password = "***";
   $mail-&gt;setFrom('jason@***.com', 'Jason');
   $mail-&gt;addReplyTo('jason@***.com', 'Jason');
   $mail-&gt;addAddress('jason@***.com', 'Jason');
   $mail-&gt;Subject = 'PHPMailer GMail SMTP test';
   $mail-&gt;msgHTML($email_message);
   $mail-&gt;AltBody = 'This is a plain-text message body';
   if (!$mail-&gt;send()) {
  echo "Mailer Error: " . $mail-&gt;ErrorInfo;
   } else {
  echo "Message sent!";
   }
   ?&gt;
  </code></pre>