Package Data | |
---|---|
Maintainer Username: | Molteber |
Maintainer Contact: | contact@mortenmehus.no (Morten Mehus) |
Package Create Date: | 2017-03-16 |
Package Last Update: | 2020-08-04 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-16 15:03:05 |
Package Statistics | |
---|---|
Total Downloads: | 14,455 |
Monthly Downloads: | 168 |
Daily Downloads: | 3 |
Total Stars: | 9 |
Total Watchers: | 2 |
Total Forks: | 3 |
Total Open Issues: | 4 |
A laravel package for changing email setting in runtime.
Note: I have set the requirements to 5.4 because it's the latest version. Have not tried the others nor made tests yet. If you want to use this package for earlier versions of laravel, create a issue and i'll make it possible, if the technique works.
composer require puz/dynamic-mail
\Puz\DynamicMail\DynamicMailServiceProvider::class,
to your list of active providers.<?php
// ...
return [
// ...
'aliases' => [
// ...
// Overwrite Laravel mailer
'Mail' => Puz\DynamicMail\Facades\DynamicMail::class,
// Own mailer
'DynamicMail' => Puz\DynamicMail\Facades\DynamicMail::class,
]
];
In the examples I have overwritten Laravel mailer facade with this packages facade.
Lets say you have these 3 situations:
config/services.php
Here is how to do so!
<?php
// 1
Mail::with(['domain' => 'another.domain.tld'])->to('..')->send('..');
// 2
Mail::via('mailgun')->to('..')->send('..');
// 3
Mail::via('mailgun')->with(['domain' => 'hello.tld', 'secret' => 'https://www.youtube.com/watch?v=Iz-8CSa9xj8'])->to('..')->send('..');
via method allows you to change the driver. Each time you use the via method, it creates a new instance of the mailer. This is so you can still use the default mailer if you'ld like. It takes a the driver name (string) as first argument, but allows you to set the config directly (as with with) in the second argument.
with is the one to set the configuration. It takes an array and takes the same array as you would do it in config/services.php
.
I did set it to only allow some of the integrated mail services you can use with Laravel. These are as follow: