Codebyjeff Laravel Quick Tip

Codebyjeff Laravel Quick Tip

Hello, Laravel Friends!
 I guess we all know about Mailchimp’s decision to no longer offer a free account to Mandrill. For many people that means switching to Mailgun, Amazon SES, Sendmail, etc.
 Switching to any of those is dead simple — the instructions are here:, but essentially you composer load either Guzzle or the Amazon library, then change the keys in your `config/services.php` file.

What if you decided to go with “Joe’s Ubercheap SecureMail”, which Laravel doesn’t offer a driver for? Well, to be perfectly honest, I would just make a wrapper around Joe’s API and keep it as simple as I could. But this isn’t a terrible time to take a quick peek at how the drivers work in case you need something more robust that fits into Laravel itself.
 The first thing to do is see what’s behind that `Mail` facade. The Facade Class Reference is here:, where we find that it references `Illuminate\Mail\Mailer`. If you look through that class, you should recognize most of the mail functionality you normally use.
 I’m going to go through the rest of this very quickly and briefly — there is a lot of code here and it gets a bit complicated at times. Fortunately, you don’t *really* need to know it, it’s just nice to have an idea about what’s going on inside your app.
 We also have a MailServiceProvider, which registers the Swift Transport instance (`TransportManager`) in a function of the same name. The TransportManager is where the code you might be expecting is happening — it looks up your mail config to see what driver you are using, and also has the wrapper code to call each specific driver itself (which are found in the `Illuminate\Mail\Transport` directory).
 So, if Joe wanted to make a native driver for Laravel, he would create a JoeTransport for his service, and ensure that he implements the correct Contract and adds his key info to the config/services.php file before finally creating a PR for it all.
 So that’s the Laravel mail drivers under the hood. Hope that helped you see a little more how things are all put together.
 By the way — this API will only pull in emails, not send them, but did you know that Mailinator has an API? I made a couple little libraries for testing emails that you’re welcome to have a look at — they are and Just for acceptance testing when you need to actually grab the email after it was delivered and confirm all is well.
 Thanks for reading! If you found this useful, help me spread the word

Read it Monday, use it by Friday!

Originally published at

Like what you read? Give LaravelFeed a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.