title: Perl Mail::Sendmail cant connect to SMTP server
body: <p>I'm trying to send an email from a perl script but I'm having a bad time connecting to my SMTP server. I'm using MailCatcher- <a href="https://github.com/sj26/mailcatcher/" rel="nofollow">https://github.com/sj26/mailcatcher/</a> - running with it's default settings (localhost:1025). </p>
  
  <p>MailCatcher is running and I can send mail to it with other services. Any clues as to what could be wrong? (Also tried sending a mail with Net::SMTP but that also failed to connect)</p>
  
  <pre><code>print "Testing Mail::Sendmail version $Mail::Sendmail::VERSION\n";
  
  my %mail = (
    To      =&gt; 'temp@test.com',
    From    =&gt; 'test@test.com',     
    Subject =&gt; 'Test message'
  );
  
  $mail{server} = 'localhost:1025';
  
  $mail{'mESSaGE : '} = "The message key looks terrible, but works.";
  
  print Dumper(%mail);
  
  if (sendmail %mail) { print "Mail sent OK.\n" }
  else { print "Error sending mail: $Mail::Sendmail::error \n" }
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>Testing Mail::Sendmail version 0.79
  Default server: localhost
  Default sender: 
  $VAR1 = 'Subject';
  $VAR2 = 'Test message';
  $VAR3 = 'server';
  $VAR4 = 'localhost:1025';
  $VAR5 = 'To';
  $VAR6 = 'temp@test.com';
  $VAR7 = 'message : ';
  $VAR8 = 'The message key looks terrible, but works.';
  $VAR9 = 'From';
  $VAR10 = 'test@test.com';
  Error sending mail: connect to localhost failed (Connection refused)
  connect to localhost failed
  connect to localhost failed (Connection refused)
  connect to localhost failed
  connect to localhost failed (Connection refused) no (more) retries!
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Turned out mailcatcher was running on another port and wasn't giving an error when I was trying to start it up on 25.</p>