Support the ongoing development of Laravel.io →
posted 8 years ago
Mail
Last updated 1 year ago.
0

You can do this by extending the default mail service provider. I was interested in this as well because of the recent news from SparkPost. Basically just copy one of the provider mail transports in to an app folder, such as app/mail/NewTransport.php. Preferably use the transport that best resembles what you are trying to implement. Then create an extended service provider that overrides the register transport function. Then de-register the default mail provider and register your extended one in the app.php config.

Here is my ExtendedMailServiceProvider.php for reference: https://gist.github.com/maxwellimpact/46ded5c553f68946d13d

Read this as well: https://laravel.com/docs/5.0/extending#container-based-extension

Ideally it would be easier to register new transports without having to override the default service provider. Especially with the ever changing landscape of web services. When I get time I may clean up what I've done so far and package it.

0

I just read a tweet from Taylor on Twitter that the latest 5.2.x release will include a SparkPost mail driver, so save yourself the trouble if thats what you are trying to implement. Hopefully they patch the ability to easily extend the transport as well (or clarify it), but if not the above should still help.

https://twitter.com/taylorotwell/status/706660698605006849

0

@maxwellimpact, thanks for that info. I'm still running on L5.0 as I'm not fully confident in upgrading without breaking a lot of stuff. The project I'm working on now was built by another dev and I just am not fully up to speed on what all he built. So, I clearly can't update to 5.2.x that has sparkpost built in. I have created that ExtendedMailServiceProvider file as you did in the App\Providers directory but you are including the App\Mail\SparkPostTransport file. Would you be willing to share that file? I hate to waste a lot of time re-inventing the wheel.

Thanks! Andrew

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.