title: How to send an email using Zend_Mail, sendmail, and localhost?
body: <p>I'm developing a zend framework application that includes a simple email function. The development version is running on my computer, which is running Ubuntu. The production version is going to run on a production server.</p>
  
  <p>When trying to send a test email to myself, I get an exception with the message: "Unable to send mail". I don't know if this is an environment issue, or a code issue. I'm not using a transport so I think it is defaulting to <code>Zend_Mail_Transport_Sendmail</code>. Here's my code:</p>
  
  <pre><code>public function sendtestAction()
  {
      $mail = new Zend_Mail();
      $mail-&gt;setFrom('test@aol.com', 'Test Email');
      $mail-&gt;addTo('my@email.com', 'My Name');
      $mail-&gt;setSubject('This is just a test.');
      $mail-&gt;setBodyText('This is only a test.');
      $mail-&gt;send();
  }
  </code></pre>
  
  <p><strong>Update:</strong> I tried a different approach by setting the SMTP transport to use localhost:</p>
  
  <pre><code>transport = new Zend_Mail_Transport_Smtp('localhost');
  Zend_Mail::setDefaultTransport($transport); 
  </code></pre>
  
  <p>I got a different error this time: "Connection refused" Not sure what that means. Maybe I haven't set something up yet?</p>
  
  <p><strong>Update:</strong> I guess I didn't have an SMTP server installed/setup. <a href="http://my.opera.com/Contrid/blog/show.dml/478684" rel="noreferrer">This tutorial made it really easy for me to get an SMTP server up an running</a>. Now both of the code samples above work.</p>