In my new work we run a Magento eCommerce store. As such, I’ve set up a fresh Vagrant Box through http://www.puphpet.com (try it!) and installed Magento into one of the vHosts. Stupidly, I forgot my password almost immediately, which highlighted a problem! Mail wasn’t sending out.
Of course, Zend_Mail defaults to using Zend_Mail_Transport_Sendmail and not Zend_Mail_Transport_Smtp, so I looked around for how to set this in Magento. Everyone on IRC told me to use 3rd party software! I checked it out, and the thing is totally insecure! https://github.com/aschroder/Magento-SMTP-Pro-Email-Extension/issues
So I decided against that.
The real answer lies in the way that Magento overrides existing classes. I told the guys in the #magento IRC channel that I refused to use the above insecure library, and would rather just hack the core ZF class.
It turns out that you can create a local directory in /app/code. So for a completely customised Zend_Mail without touching third party vendor files (ie. the ZF lib), you create /app/code/local/Zend/Mail.php, and tweak away to your liking!
line 1175 is the culprit . Change
$transport = new Zend_Mail_Transport_Sendmail(); // the ZF default to $transport = new Zend_Mail_Transport_Smtp();
Lastly, if you need to set a custom port (on my dev box, I wanted all my mail going through port 1025 so that Mailcatcher would stop development mails going out), then run the following SQL query on your DB:
INSERT INTO `core_config_data` (`config_id`, `scope`, `scope_id`, `path`, `value`) VALUES (NULL, 'default', 0, 'system/smtp/port', '1025');
If you set a db prefix then tweak the above table name to suit. That should be you ready to rock! Have fun!