Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion publish/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
],

'log' => [
'dsn' => 'log://',
'transport' => \HyperfExt\Mail\Transport\LogTransport::class,
'options' => [
'name' => 'mail.local',
Expand Down
8 changes: 4 additions & 4 deletions src/MailManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ public function send(MailableInterface $mailable): void
*/
protected function createTransport(array $config): TransportInterface
{
if (empty($config['dsn'])) {
throw new InvalidArgumentException('The mail transport DSN must be specified.');
if (!empty($config['transport'])) {
return make($config['transport'], ['options' => $config['options'] ?? []]);
}

if ($config['dsn'] === 'log://') {
return make($config['transport'], ['options' => $config['options'] ?? []]);
if (empty($config['dsn'])) {
throw new InvalidArgumentException('The mail transport DSN must be specified.');
}

$logger = null;
Expand Down
7 changes: 5 additions & 2 deletions src/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ protected function hasRecipient(

protected function buildView(array $data): array
{
Coroutine::create(function () use ($data, &$html, &$plain) {
$chan = new \Swoole\Coroutine\Channel(1);
Coroutine::create(function () use ($data, $chan) {
if (! empty($this->locale)) {
ApplicationContext::getContainer()->get(TranslatorInterface::class)->setLocale($this->locale);
}
Expand All @@ -511,9 +512,11 @@ protected function buildView(array $data): array
} elseif (! empty($this->textViewTemplate)) {
$plain = $this->renderView($this->textViewTemplate, $data);
}

$chan->push([$html, $plain]);
});

return [$html, $plain];
return $chan->pop();
}

/**
Expand Down