title: PHPMailer: Using remote SMTP server, works under localhost, Connection refused (111) on remote server
body: <p>I've got a bizarre problem here. I'm trying to use PHPMailer to send an email, through SMTP. I have a website hosted by GoDaddy and it's that SMTP account that I'm trying to use to send the mail.</p>
  
  <ol>
  <li>It works if I execute my PHP file on my localhost server.</li>
  <li>It does not work if I execute my PHP file on GoDaddy's server.</li>
  </ol>
  
  <p>The error message I get is:</p>
  
  <p><code>SMTP -&gt; ERROR: Failed to connect to server: Connection refused (111)</code></p>
  
  <p>I checked <code>phpinfo</code> on both localhost and the remote server. Both have <code>smtp_port</code> listed as <code>25</code>. I'm using WAMP on my machine and the server is some form of Linux (which I know nothing about and have no idea how to administer).</p>
  
  <p>Here is the code in question:</p>
  
  <p><strong>INDEX.PHP</strong>:</p>
  
  <pre><code>&lt;?php
  date_default_timezone_set('America/Los_Angeles');
  include_once("phpmailer/class.phpmailer.php");
  
  $mail = new PHPMailer;
  $mail-&gt;SMTPDebug = 1;
  $mail-&gt;Port = 25;
  
  $mail-&gt;IsSMTP();
  $mail-&gt;Host = 'smtpout.secureserver.net';
  $mail-&gt;SMTPAuth = true;
  $mail-&gt;Username = 'username@site.com';
  $mail-&gt;Password = 'super_secret_password';
  $mail-&gt;SMTPSecure = ''; // tried ssl and tls, with same result
  
  $mail-&gt;ClearAddresses();
  $mail-&gt;AddAddress('receiver@hotmail.com', 'Receiver Name');
  $mail-&gt;From = "username@site.com";
  $mail-&gt;FromName = "Username";
  $mail-&gt;Subject = 'Hi there';
  $mail-&gt;Body = "This is a message";
  
  if ($mail-&gt;Send()) {
      echo "Message sent!\n";
  }
  else {
      echo "Message failed!\n";
      print_r($mail-&gt;ErrorInfo);
  }
  
  exit();
  ?&gt;
  </code></pre>