Service provider for laravel which provide Mirfalah Swift_Transport implementation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MirfalahSendmailServiceProvider.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace MirfalahTech\Laravel\Mail;
  3. use Illuminate\Contracts\Config\Repository;
  4. use Illuminate\Contracts\Container\BindingResolutionException;
  5. use Illuminate\Contracts\Container\Container;
  6. use Illuminate\Mail\TransportManager;
  7. use Illuminate\Support\AggregateServiceProvider;
  8. use MirfalahTech\Swift\MirfalahTransport;
  9. class MirfalahSendmailServiceProvider extends AggregateServiceProvider
  10. {
  11. /**
  12. * @throws BindingResolutionException
  13. */
  14. public function boot()
  15. {
  16. /** @var Repository $config */
  17. $config = $this->app->make('config');
  18. $config->set([
  19. 'mail.mirfalah' => array_merge([
  20. 'api_key' => env('MIRFALAH_SENDMAIL_APIKEY'),
  21. 'secret' => env('MIRFALAH_SENDMAIL_SECRET'),
  22. 'endpoint' => env(
  23. 'MIRFALAH_SENDMAIL_ENDPOINT',
  24. 'https://pahangmail.mirfalah.my/mirfalah-sendmail/index.php'
  25. ),
  26. ], $config->get('mail.mirfalah', []))
  27. ]);
  28. $this->app->afterResolving('swift.transport',
  29. function (TransportManager $manager) use ($config) {
  30. $manager->extend('mirfalah', function (Container $app) use ($config) {
  31. return new MirfalahTransport(
  32. $config->get('mail.mirfalah.api_key', env('MIRFALAH_SENDMAIL_APIKEY')),
  33. $config->get('mail.mirfalah.secret', env('MIRFALAH_SENDMAIL_SECRET')),
  34. $config->get('mail.mirfalah.endpoint', env('MIRFALAH_SENDMAIL_ENDPOINT'))
  35. );
  36. });
  37. });
  38. }
  39. }