Skip to content

Commit

Permalink
Allow specifying mailer in php artisan send-test-mail
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Dec 18, 2023
1 parent 4520682 commit 116d990
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ See [GitHub releases](https://github.com/mll-lab/laravel-utils/releases).

## Unreleased

## v4.8.0

### Added

- Allow specifying mailer in `php artisan send-test-mail`

## v4.7.0

### Added
Expand Down
10 changes: 9 additions & 1 deletion src/Mail/SendTestMailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class SendTestMailCommand extends Command
send-test-mail
{--from= : Sender}
{--to= : Recipient}
{--mailer= : See config/mail.php mailers}
';

public function handle(): void
Expand All @@ -31,6 +32,13 @@ public function handle(): void
->from($from)
->to($to);

Mail::send($mail);
$mailer = $this->option('mailer');
if (! is_null($mailer) && ! is_string($mailer)) { // @phpstan-ignore-line
$mailerType = gettype($mailer);
throw new \UnexpectedValueException("Expected option --mailer to be string or null, got {$mailerType}.");
}

Mail::mailer($mailer)
->send($mail);
}
}

0 comments on commit 116d990

Please sign in to comment.