title: PHP SMTP Not working with Amazon SES
body: <p>I'm having a problem sending emails out through SMTP using Amazons SES. My code is relatively simple and looks like this:</p>
  
  <pre><code>require_once "Mail.php";
              require_once 'Mail/mime.php';
  $stmp_info= array (
                  'host' =&gt; 'ssl://email-smtp.us-east-1.amazonaws.com',
                  'port' =&gt; 465,
                  'auth' =&gt; true,
                  'username' =&gt; 'xxxxxx',
                  'password' =&gt; 'xxx'
              );
  
              $headers = array (
                  'From' =&gt; 'sender@example.com',
                  'To' =&gt; 'test@example.com',
                  'Subject' =&gt; 'Test Message'
              );
  
  $mime = new Mail_mime("\n");
  $mime-&gt;setTXTBody('Hello World');
  $mime-&gt;setHTMLBody('&lt;p&gt;Hello World&lt;/p&gt;');
  
  $body = $mime-&gt;get();
  $headers = $mime-&gt;headers($headers);
  
  $smtp = Mail::factory('smtp', $stmp_info);
  $mail = $smtp-&gt;send('test@example.com', $headers, $body);
  </code></pre>
  
  <p>The problem is I always get this error:</p>
  
  <pre><code>Failed to connect to email-smtp.us-east-1.amazonaws.com:465 [SMTP: Invalid response code received from server (code: -1, response: )]
  </code></pre>
  
  <p>But this works for testing a connection:</p>
  
  <pre><code>[root@job-server-1 ~]# $ echo quit | nc -v email-smtp.us-east-1.amazonaws.com 25
  -bash: $: command not found
  Connection to email-smtp.us-east-1.amazonaws.com 25 port [tcp/smtp] succeeded!
  220 email-smtp.amazonaws.com ESMTP SimpleEmailService-376766033
  </code></pre>
  
  <p>Yet if I ping the address, it does not work. I've tried port 25, 465 and 587 for both tls and ssl. The weird part is it works on my local host and this error only occurs when I try to connect from my rackspace instance. Does anyoen have an idea of what can be causing this?</p>