TOGoS PHP Mail, a simple e-mail API
tl;dr: This project’s here for historical interest. You probably want to use Swiftmailer instead.
Sending e-mail in PHP used to be kind of a pain! There were some built-in functions to do it, but the API was awkward to use directly and everyone wrapped it. Different web frameworks each provided their own overcomplicated e-mail system, often bound up with some templating engine or other such unwanted crud.
TOGoS PHP Mail library solved that, and provided a simple API to provide a point of separation between the application and whatever e-mail transport mechanism you decided to use (and a simple transport interface in case you had to write your own, which you probably would because I didn’t have time to write every implementation that anyone might need).
Included are interfaces/classes to represent e-mail messages in a simple way (interfaces just declare getter methods for basic mail attributes), and some different transports:
- ZendTransport, for when you’ve got Zend Framework (whichever version we were using in 2011) classes lying around, along with a utility class to retrieve the Zend transport object to be wrapped, because Zend for some reason didn’t include that???
- SendmailTransport, which just calls the
mail
function. - SanityCheckingTransport, which will check that your messages look reasonable (have a sender and recipient, all e-mail addresses have exactly one “@” in them) before forwarding to another, wrapped transport if they are, and throwing an exception or logging an error (as configured) otherwise.
- RedirectingTransport, useful for staging/development environments, which rewrites messages such that they all go to some other configured address before passing them on to another, wrapped transport.
This was a huge step forward, but then Swiftmailer came around and made it redundant. But then Swiftmailer is probably a lot more lines of code? So if you need something really small, maybe TOGoS PHP Mail is for you!