laravel/framework — pull request #5032 by driesvints (2014-07-11 23:18:13+00:00)
Title: [Proposal] De-couple mail component a bit

I wrote this PR because recently I tried integrating the mail component in a legacy Zend 1 app. I noticed some caveats with using it because at some points it was pretty tightly coupled to the Laravel framework. I made some improvements to decouple it a bit more so others may use it more easily in applications different then Laravel. This PR should be without BC breaks so I could also send this to 4.2 if you'd like. Let me know.

Improvements:
- Usage of an interface and trait for the log writer class. This allows us to more easily use our own log classes in Laravel components. I've replaced the hard-coded Writer dependency in the Mailer class with the interface so we can now easily use our own loggers with the mail component.
- I've added Guzzle as a suggest in `composer.json`. I didn't get the mandrill component working immediately and it turned out that it was because Guzzle didn't came along as a dependency. While I agree that it may be overkill to always include it in the "require" list we should definitely let developers know to install it if they want to use the Mailgun or Mandrill driver.
- Currently, the logic for choosing a transport based on the selected driver is hardcoded into the service provider. This makes it virtually impossible to use it outside of Laravel. I ended up just copy/pasting all the code. I've moved this to an external class so it's easier to re-use.
- Some minor docblock and namespace import fixes.

Hope you like it! I'll write a blog post on how to integrate the mail component into other apps after this gets merged in. Enjoy!

PS.: I'm still wondering about cutting out the config repository as a constructor argument and just pass along an array with all the options. This will make it even more easier to re-use outside Laravel. What do you think?