diff --git a/extensions/mentions/views/emails/html/groupMentioned.blade.php b/extensions/mentions/views/emails/html/groupMentioned.blade.php
index d6aff59247..89e2ebfa89 100644
--- a/extensions/mentions/views/emails/html/groupMentioned.blade.php
+++ b/extensions/mentions/views/emails/html/groupMentioned.blade.php
@@ -1,13 +1,13 @@
-@extends('flarum.forum::email.html.notification.base')
+
+
+ {!! $formatter->convert($translator->trans('flarum-mentions.email.group_mentioned.html.body', [
+ '{mentioner_display_name}' => $blueprint->post->user->display_name,
+ '{title}' => $blueprint->post->discussion->title,
+ '{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number])
+ ])) !!}
+
-@section('notificationContent')
-{!! $formatter->convert($translator->trans('flarum-mentions.email.group_mentioned.html.body', [
-'{mentioner_display_name}' => $blueprint->post->user->display_name,
-'{title}' => $blueprint->post->discussion->title,
-'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number])
-])) !!}
-@endsection
-
-@section('contentPreview')
- {!! $blueprint->post->formatContent() !!}
-@endsection
+
+ {!! $blueprint->post->formatContent() !!}
+
+
diff --git a/extensions/mentions/views/emails/html/postMentioned.blade.php b/extensions/mentions/views/emails/html/postMentioned.blade.php
index 02a1462bc7..007e0680a5 100644
--- a/extensions/mentions/views/emails/html/postMentioned.blade.php
+++ b/extensions/mentions/views/emails/html/postMentioned.blade.php
@@ -1,14 +1,14 @@
-@extends('flarum.forum::email.html.notification.base')
+
+
+ {!! $formatter->convert($translator->trans('flarum-mentions.email.post_mentioned.html.body', [
+ '{replier_display_name}' => $blueprint->reply->user->display_name,
+ '{post_number}' => $blueprint->post->number,
+ '{title}' => $blueprint->post->discussion->title,
+ '{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->reply->discussion_id, 'near' => $blueprint->reply->number])
+ ])) !!}
+
-@section('notificationContent')
-{!! $formatter->convert($translator->trans('flarum-mentions.email.post_mentioned.html.body', [
-'{replier_display_name}' => $blueprint->reply->user->display_name,
-'{post_number}' => $blueprint->post->number,
-'{title}' => $blueprint->post->discussion->title,
-'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->reply->discussion_id, 'near' => $blueprint->reply->number])
-])) !!}
-@endsection
-
-@section('contentPreview')
- {!! $blueprint->reply->formatContent() !!}
-@endsection
+
+ {!! $blueprint->reply->formatContent() !!}
+
+
diff --git a/extensions/mentions/views/emails/html/userMentioned.blade.php b/extensions/mentions/views/emails/html/userMentioned.blade.php
index aa085e0b16..e0a5e39b7a 100644
--- a/extensions/mentions/views/emails/html/userMentioned.blade.php
+++ b/extensions/mentions/views/emails/html/userMentioned.blade.php
@@ -1,13 +1,13 @@
-@extends('flarum.forum::email.html.notification.base')
+
+
+ {!! $formatter->convert($translator->trans('flarum-mentions.email.user_mentioned.html.body', [
+ '{mentioner_display_name}' => $blueprint->post->user->display_name,
+ '{title}' => $blueprint->post->discussion->title,
+ '{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number])
+ ])) !!}
+
-@section('notificationContent')
-{!! $formatter->convert($translator->trans('flarum-mentions.email.user_mentioned.html.body', [
-'{mentioner_display_name}' => $blueprint->post->user->display_name,
-'{title}' => $blueprint->post->discussion->title,
-'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number])
-])) !!}
-@endsection
-
-@section('contentPreview')
- {!! $blueprint->post->formatContent() !!}
-@endsection
+
+ {!! $blueprint->post->formatContent() !!}
+
+
diff --git a/extensions/mentions/views/emails/plain/groupMentioned.blade.php b/extensions/mentions/views/emails/plain/groupMentioned.blade.php
index 569f74238a..2b3f5d4c82 100644
--- a/extensions/mentions/views/emails/plain/groupMentioned.blade.php
+++ b/extensions/mentions/views/emails/plain/groupMentioned.blade.php
@@ -1,10 +1,10 @@
-@extends('flarum.forum::email.plain.notification.base')
-
-@section('content')
+
+
{!! $translator->trans('flarum-mentions.email.group_mentioned.plain.body', [
'{mentioner_display_name}' => $blueprint->post->user->display_name,
'{title}' => $blueprint->post->discussion->title,
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number]),
'{content}' => $blueprint->post->content
]) !!}
-@endsection
+
+
diff --git a/extensions/mentions/views/emails/plain/postMentioned.blade.php b/extensions/mentions/views/emails/plain/postMentioned.blade.php
index daae1a4d27..3972dd2473 100644
--- a/extensions/mentions/views/emails/plain/postMentioned.blade.php
+++ b/extensions/mentions/views/emails/plain/postMentioned.blade.php
@@ -1,6 +1,5 @@
-@extends('flarum.forum::email.plain.notification.base')
-
-@section('content')
+
+
{!! $translator->trans('flarum-mentions.email.post_mentioned.plain.body', [
'{replier_display_name}' => $blueprint->reply->user->display_name,
'{post_number}' => $blueprint->post->number,
@@ -8,4 +7,5 @@
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->reply->discussion_id, 'near' => $blueprint->reply->number]),
'{content}' => $blueprint->reply->content
]) !!}
-@endsection
+
+
diff --git a/extensions/mentions/views/emails/plain/userMentioned.blade.php b/extensions/mentions/views/emails/plain/userMentioned.blade.php
index e642aaf2a0..fc076ecf4f 100644
--- a/extensions/mentions/views/emails/plain/userMentioned.blade.php
+++ b/extensions/mentions/views/emails/plain/userMentioned.blade.php
@@ -1,10 +1,10 @@
-@extends('flarum.forum::email.plain.notification.base')
-
-@section('content')
+
+
{!! $translator->trans('flarum-mentions.email.user_mentioned.plain.body', [
'{mentioner_display_name}' => $blueprint->post->user->display_name,
'{title}' => $blueprint->post->discussion->title,
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number]),
'{content}' => $blueprint->post->content
]) !!}
-@endsection
+
+
diff --git a/extensions/messages/views/emails/html/messageReceived.blade.php b/extensions/messages/views/emails/html/messageReceived.blade.php
index f07ae20b84..9eb1a71ff5 100644
--- a/extensions/messages/views/emails/html/messageReceived.blade.php
+++ b/extensions/messages/views/emails/html/messageReceived.blade.php
@@ -2,15 +2,15 @@
/** @var \Flarum\Messages\Notification\MessageReceivedBlueprint $blueprint */
@endphp
-@extends('flarum.forum::email.html.notification.base')
+
+
+ {!! $formatter->convert($translator->trans('flarum-messages.email.message_received.html.body', [
+ '{user_display_name}' => $blueprint->message->user->display_name,
+ '{url}' => $url->to('forum')->route('messages.dialog', ['id' => $blueprint->message->dialog_id, 'near' => $blueprint->message->id])
+ ])) !!}
+
-@section('notificationContent')
-{!! $formatter->convert($translator->trans('flarum-messages.email.message_received.html.body', [
-'{user_display_name}' => $blueprint->message->user->display_name,
-'{url}' => $url->to('forum')->route('messages.dialog', ['id' => $blueprint->message->dialog_id, 'near' => $blueprint->message->id])
-])) !!}
-@endsection
-
-@section('contentPreview')
- {!! $blueprint->message->formatContent() !!}
-@endsection
+
+ {!! $blueprint->message->formatContent() !!}
+
+
diff --git a/extensions/messages/views/emails/plain/messageReceived.blade.php b/extensions/messages/views/emails/plain/messageReceived.blade.php
index 01f7fbc488..e95bb390d1 100644
--- a/extensions/messages/views/emails/plain/messageReceived.blade.php
+++ b/extensions/messages/views/emails/plain/messageReceived.blade.php
@@ -2,12 +2,12 @@
/** @var \Flarum\Messages\Notification\MessageReceivedBlueprint $blueprint */
@endphp
-@extends('flarum.forum::email.plain.notification.base')
-
-@section('content')
+
+
{!! $translator->trans('flarum-messages.email.message_received.plain.body', [
'{user_display_name}' => $blueprint->message->user->display_name,
'{url}' => $url->to('forum')->route('messages.dialog', ['id' => $blueprint->message->dialog_id, 'near' => $blueprint->message->id]),
'{content}' => $blueprint->message->content
]) !!}
-@endsection
+
+
diff --git a/extensions/subscriptions/views/emails/html/newPost.blade.php b/extensions/subscriptions/views/emails/html/newPost.blade.php
index 8b1d15620d..0f810c1b06 100644
--- a/extensions/subscriptions/views/emails/html/newPost.blade.php
+++ b/extensions/subscriptions/views/emails/html/newPost.blade.php
@@ -1,13 +1,13 @@
-@extends('flarum.forum::email.html.notification.base')
+
+
+ {!! $formatter->convert($translator->trans('flarum-subscriptions.email.new_post.html.body', [
+ '{poster_display_name}' => $blueprint->post->user->display_name,
+ '{title}' => $blueprint->post->discussion->title,
+ '{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number])
+ ])) !!}
+
-@section('notificationContent')
-{!! $formatter->convert($translator->trans('flarum-subscriptions.email.new_post.html.body', [
-'{poster_display_name}' => $blueprint->post->user->display_name,
-'{title}' => $blueprint->post->discussion->title,
-'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number])
-])) !!}
-@endsection
-
-@section('contentPreview')
- {!! $blueprint->post->formatContent() !!}
-@endsection
+
+ {!! $blueprint->post->formatContent() !!}
+
+
diff --git a/extensions/subscriptions/views/emails/plain/newPost.blade.php b/extensions/subscriptions/views/emails/plain/newPost.blade.php
index 09bc166ca5..5713ccb971 100644
--- a/extensions/subscriptions/views/emails/plain/newPost.blade.php
+++ b/extensions/subscriptions/views/emails/plain/newPost.blade.php
@@ -1,10 +1,10 @@
-@extends('flarum.forum::email.plain.notification.base')
-
-@section('content')
+
+
{!! $translator->trans('flarum-subscriptions.email.new_post.plain.body', [
'{poster_display_name}' => $blueprint->post->user->display_name,
'{title}' => $blueprint->post->discussion->title,
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number]),
'{content}' => $blueprint->post->content
]) !!}
-@endsection
+
+
diff --git a/extensions/suspend/views/emails/html/suspended.blade.php b/extensions/suspend/views/emails/html/suspended.blade.php
index 0cdfffddf2..27868fcb1d 100644
--- a/extensions/suspend/views/emails/html/suspended.blade.php
+++ b/extensions/suspend/views/emails/html/suspended.blade.php
@@ -1,11 +1,11 @@
-@extends('flarum.forum::email.html.information.base')
+
+
+ {!! $formatter->convert($translator->trans('flarum-suspend.email.suspended.html.body', [
+ '{forumTitle}' => $settings->get('forum_title')
+ ])) !!}
+
-@section('informationContent')
-{!! $formatter->convert($translator->trans('flarum-suspend.email.suspended.html.body', [
-'{forumTitle}' => $settings->get('forum_title')
-])) !!}
-@endsection
-
-@section('contentPreview')
- {!! $formatter->convert($blueprint->user->suspend_message ?? $translator->trans('flarum-suspend.email.no_reason_given')) !!}
-@endsection
+
+ {!! $formatter->convert($blueprint->user->suspend_message ?? $translator->trans('flarum-suspend.email.no_reason_given')) !!}
+
+
diff --git a/extensions/suspend/views/emails/html/unsuspended.blade.php b/extensions/suspend/views/emails/html/unsuspended.blade.php
index 34ba25374b..b55c2df847 100644
--- a/extensions/suspend/views/emails/html/unsuspended.blade.php
+++ b/extensions/suspend/views/emails/html/unsuspended.blade.php
@@ -1,8 +1,8 @@
-@extends('flarum.forum::email.html.information.base')
-
-@section('content')
-{!! $formatter->convert($translator->trans('flarum-suspend.email.unsuspended.html.body', [
-'{forumTitle}' => $settings->get('forum_title'),
-'{forum_url}' => $url->to('forum')->base(),
-])) !!}
-@endsection
+
+
+ {!! $formatter->convert($translator->trans('flarum-suspend.email.unsuspended.html.body', [
+ '{forumTitle}' => $settings->get('forum_title'),
+ '{forum_url}' => $url->to('forum')->base(),
+ ])) !!}
+
+
diff --git a/extensions/suspend/views/emails/plain/suspended.blade.php b/extensions/suspend/views/emails/plain/suspended.blade.php
index b752be9cd5..c00944807e 100644
--- a/extensions/suspend/views/emails/plain/suspended.blade.php
+++ b/extensions/suspend/views/emails/plain/suspended.blade.php
@@ -1,7 +1,7 @@
-@extends('flarum.forum::email.plain.information.base')
-
-@section('content')
+
+
{!! $translator->trans('flarum-suspend.email.suspended.plain.body', [
'{suspension_message}' => $blueprint->user->suspend_message ?? $translator->trans('flarum-suspend.email.no_reason_given'),
]) !!}
-@endsection
+
+
diff --git a/extensions/suspend/views/emails/plain/unsuspended.blade.php b/extensions/suspend/views/emails/plain/unsuspended.blade.php
index 8b7cfa2482..6f66ec3ea6 100644
--- a/extensions/suspend/views/emails/plain/unsuspended.blade.php
+++ b/extensions/suspend/views/emails/plain/unsuspended.blade.php
@@ -1,7 +1,7 @@
-@extends('flarum.forum::email.plain.information.base')
-
-@section('content')
+
+
{!! $translator->trans('flarum-suspend.email.unsuspended.plain.body', [
'{forum_url}' => $url->to('forum')->base(),
]) !!}
-@endsection
+
+
diff --git a/framework/core/src/Mail/Job/SendInformationalEmailJob.php b/framework/core/src/Mail/Job/SendInformationalEmailJob.php
index 88b3130a8d..7dc909f122 100644
--- a/framework/core/src/Mail/Job/SendInformationalEmailJob.php
+++ b/framework/core/src/Mail/Job/SendInformationalEmailJob.php
@@ -11,6 +11,7 @@
use Flarum\Queue\AbstractJob;
use Illuminate\Contracts\Mail\Mailer;
+use Illuminate\Contracts\View\Factory;
use Illuminate\Mail\Message;
class SendInformationalEmailJob extends AbstractJob
@@ -23,13 +24,13 @@ public function __construct(
private readonly string $forumTitle,
private readonly ?string $bodyTitle = null,
protected array $views = [
- 'text' => 'flarum.forum::email.plain.information.base',
- 'html' => 'flarum.forum::email.html.information.base'
+ 'text' => 'mail::plain.information.generic',
+ 'html' => 'mail::html.information.generic'
]
) {
}
- public function handle(Mailer $mailer): void
+ public function handle(Mailer $mailer, Factory $view): void
{
$forumTitle = $this->forumTitle;
$infoContent = $this->body;
@@ -37,9 +38,11 @@ public function handle(Mailer $mailer): void
$title = $this->bodyTitle;
$username = $this->displayName;
+ $view->share(compact('forumTitle', 'userEmail', 'title', 'username'));
+
$mailer->send(
$this->views,
- compact('forumTitle', 'infoContent', 'userEmail', 'title', 'username'),
+ compact('infoContent'),
function (Message $message) {
$message->to($this->email);
$message->subject($this->subject);
diff --git a/framework/core/src/Mail/MailServiceProvider.php b/framework/core/src/Mail/MailServiceProvider.php
index 749b224128..8467324d18 100644
--- a/framework/core/src/Mail/MailServiceProvider.php
+++ b/framework/core/src/Mail/MailServiceProvider.php
@@ -83,6 +83,10 @@ public function register(): void
});
$this->container->alias('mailer', MailerContract::class);
+
+ $this->container->afterResolving(\Illuminate\Contracts\View\Factory::class, function (\Illuminate\Contracts\View\Factory $blade) {
+ $blade->addNamespace('mail', __DIR__.'/../../views/email');
+ });
}
public function boot(Dispatcher $events): void
diff --git a/framework/core/src/Notification/NotificationMailer.php b/framework/core/src/Notification/NotificationMailer.php
index 45b4948700..2651ca0565 100644
--- a/framework/core/src/Notification/NotificationMailer.php
+++ b/framework/core/src/Notification/NotificationMailer.php
@@ -15,6 +15,7 @@
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\User\User;
use Illuminate\Contracts\Mail\Mailer;
+use Illuminate\Contracts\View\Factory;
use Illuminate\Mail\Message;
use Illuminate\Support\Arr;
@@ -24,7 +25,8 @@ public function __construct(
protected Mailer $mailer,
protected TranslatorInterface $translator,
protected SettingsRepositoryInterface $settings,
- protected UrlGenerator $url
+ protected UrlGenerator $url,
+ protected Factory $view,
) {
}
@@ -44,9 +46,13 @@ public function send(MailableInterface&BlueprintInterface $blueprint, User $user
$username = $user->display_name;
$userEmail = $user->email;
+ $data = compact('blueprint', 'user', 'unsubscribeLink', 'settingsLink', 'type', 'forumTitle', 'username', 'userEmail');
+
+ $this->view->share($data);
+
$this->mailer->send(
$this->getEmailViews($blueprint),
- compact('blueprint', 'user', 'unsubscribeLink', 'settingsLink', 'type', 'forumTitle', 'username', 'userEmail'),
+ $data,
function (Message $message) use ($blueprint, $user) {
$message->to($user->email, $user->display_name)
->subject($blueprint->getEmailSubject($this->translator));
diff --git a/framework/core/views/email/html/base.blade.php b/framework/core/views/email/html.blade.php
similarity index 96%
rename from framework/core/views/email/html/base.blade.php
rename to framework/core/views/email/html.blade.php
index b847fd67b1..8a529f53dd 100644
--- a/framework/core/views/email/html/base.blade.php
+++ b/framework/core/views/email/html.blade.php
@@ -57,7 +57,7 @@
@endif
- @yield('header')
+ {{ $header ?? '' }}
@@ -67,7 +67,7 @@
@endif
- @yield('content')
+ {{ $content ?? '' }}
@if(!isset($signoff) || $signoff !== false)
@@ -77,7 +77,7 @@