12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
-
-
- namespace MirfalahTech\Laravel\Mail;
-
-
- use Illuminate\Contracts\Config\Repository;
- use Illuminate\Contracts\Container\BindingResolutionException;
- use Illuminate\Contracts\Container\Container;
- use Illuminate\Mail\TransportManager;
- use Illuminate\Support\AggregateServiceProvider;
- use MirfalahTech\Swift\MirfalahTransport;
-
- class MirfalahSendmailServiceProvider extends AggregateServiceProvider
- {
- /**
- * @throws BindingResolutionException
- */
- public function boot()
- {
- /** @var Repository $config */
- $config = $this->app->make('config');
-
- $config->set([
- 'mail.mirfalah' => array_merge([
- 'api_key' => env('MIRFALAH_SENDMAIL_APIKEY'),
- 'secret' => env('MIRFALAH_SENDMAIL_SECRET'),
- 'endpoint' => env(
- 'MIRFALAH_SENDMAIL_ENDPOINT',
- 'https://pahangmail.mirfalah.my/mirfalah-sendmail/index.php'
- ),
- ], $config->get('mail.mirfalah', []))
- ]);
-
- $this->app->afterResolving('swift.transport',
- function (TransportManager $manager) use ($config) {
- $manager->extend('mirfalah', function (Container $app) use ($config) {
- return new MirfalahTransport(
- $config->get('mail.mirfalah.api_key', env('MIRFALAH_SENDMAIL_APIKEY')),
- $config->get('mail.mirfalah.secret', env('MIRFALAH_SENDMAIL_SECRET')),
- $config->get('mail.mirfalah.endpoint', env('MIRFALAH_SENDMAIL_ENDPOINT'))
- );
- });
- });
- }
- }
|