Craig Marvelley

Software and such

Sending Emails With PHP Using Swiftmailer and SMTP on Mac OSX

I’m a fan of Swiftmailer for sending emails through PHP – it’s a much more elegant alternative to the mail()function and recently was absorbed into the Symfony project, so its future seems certain. A big plus is its support for sending mail using the <a href="ht<code></code>tp://">SMTP</a> protocol, which makes it great for more complex scenarios where authentication or performance are concerns.

Up until this week I’d only used Swiftmailer on Windows, with an SMTP server on our network. This changed when I needed to do a demonstration using my Macbook, and as OSX comes installed with Postfix I thought everything should just work if I configured Swiftmailer to use an SMTP server on localhost at the standard port (25). This was nearly the case – as I read here while Postfix is installed, it’s not enabled by default. After following the steps outlined there email started sending as expected.