From 9b13120c41f4cce590d27321625f4f5b01527795 Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Tue, 12 Sep 2017 20:23:48 +0100 Subject: [PATCH] #6: Updated the mailing config to use Markdown. Converted the current e-mail templates to Markdown. --- app/Http/Middleware/AppInstallation.php | 2 + app/Mail/TestMailConfig.php | 2 +- app/Mail/UserActivationRequired.php | 2 +- config/mail.php | 16 + resources/lang/en/forms.php | 1 + .../themes/base/email/test_email.blade.php | 16 +- .../email/user_activation_required.blade.php | 30 +- .../themes/base/partials/register.blade.php | 24 +- .../views/vendor/mail/html/button.blade.php | 19 ++ .../views/vendor/mail/html/footer.blade.php | 11 + .../views/vendor/mail/html/header.blade.php | 7 + .../views/vendor/mail/html/layout.blade.php | 54 ++++ .../views/vendor/mail/html/message.blade.php | 27 ++ .../views/vendor/mail/html/panel.blade.php | 13 + .../vendor/mail/html/promotion.blade.php | 7 + .../mail/html/promotion/button.blade.php | 13 + .../views/vendor/mail/html/subcopy.blade.php | 7 + .../views/vendor/mail/html/table.blade.php | 3 + .../views/vendor/mail/html/themes/default.css | 285 ++++++++++++++++++ .../vendor/mail/markdown/button.blade.php | 1 + .../vendor/mail/markdown/footer.blade.php | 1 + .../vendor/mail/markdown/header.blade.php | 1 + .../vendor/mail/markdown/layout.blade.php | 9 + .../vendor/mail/markdown/message.blade.php | 27 ++ .../vendor/mail/markdown/panel.blade.php | 1 + .../vendor/mail/markdown/promotion.blade.php | 1 + .../mail/markdown/promotion/button.blade.php | 1 + .../vendor/mail/markdown/subcopy.blade.php | 1 + .../vendor/mail/markdown/table.blade.php | 1 + 29 files changed, 547 insertions(+), 36 deletions(-) create mode 100644 resources/views/vendor/mail/html/button.blade.php create mode 100644 resources/views/vendor/mail/html/footer.blade.php create mode 100644 resources/views/vendor/mail/html/header.blade.php create mode 100644 resources/views/vendor/mail/html/layout.blade.php create mode 100644 resources/views/vendor/mail/html/message.blade.php create mode 100644 resources/views/vendor/mail/html/panel.blade.php create mode 100644 resources/views/vendor/mail/html/promotion.blade.php create mode 100644 resources/views/vendor/mail/html/promotion/button.blade.php create mode 100644 resources/views/vendor/mail/html/subcopy.blade.php create mode 100644 resources/views/vendor/mail/html/table.blade.php create mode 100644 resources/views/vendor/mail/html/themes/default.css create mode 100644 resources/views/vendor/mail/markdown/button.blade.php create mode 100644 resources/views/vendor/mail/markdown/footer.blade.php create mode 100644 resources/views/vendor/mail/markdown/header.blade.php create mode 100644 resources/views/vendor/mail/markdown/layout.blade.php create mode 100644 resources/views/vendor/mail/markdown/message.blade.php create mode 100644 resources/views/vendor/mail/markdown/panel.blade.php create mode 100644 resources/views/vendor/mail/markdown/promotion.blade.php create mode 100644 resources/views/vendor/mail/markdown/promotion/button.blade.php create mode 100644 resources/views/vendor/mail/markdown/subcopy.blade.php create mode 100644 resources/views/vendor/mail/markdown/table.blade.php diff --git a/app/Http/Middleware/AppInstallation.php b/app/Http/Middleware/AppInstallation.php index fba5ab0..0f670b5 100644 --- a/app/Http/Middleware/AppInstallation.php +++ b/app/Http/Middleware/AppInstallation.php @@ -94,7 +94,9 @@ class AppInstallation { Log::info('Upgrading database', ['new_version' => $appVersionNumber]); + Artisan::call('config:cache'); Artisan::call('cache:clear'); + Artisan::call('view:clear'); Artisan::call('migrate', ['--force' => true]); Artisan::call('db:seed', ['--force' => true]); diff --git a/app/Mail/TestMailConfig.php b/app/Mail/TestMailConfig.php index 4f33c16..86df647 100644 --- a/app/Mail/TestMailConfig.php +++ b/app/Mail/TestMailConfig.php @@ -37,7 +37,7 @@ class TestMailConfig extends Mailable return $this ->subject($subject) - ->view(Theme::viewName('email.test_email')) + ->markdown(Theme::viewName('email.test_email')) ->with(['subject' => $subject]); } } diff --git a/app/Mail/UserActivationRequired.php b/app/Mail/UserActivationRequired.php index 7aa3fe0..9b94c0e 100644 --- a/app/Mail/UserActivationRequired.php +++ b/app/Mail/UserActivationRequired.php @@ -37,7 +37,7 @@ class UserActivationRequired extends Mailable return $this ->subject($subject) - ->view(Theme::viewName('email.user_activation_required')) + ->markdown(Theme::viewName('email.user_activation_required')) ->with([ 'subject' => $subject, 'user' => $this->user diff --git a/config/mail.php b/config/mail.php index be962b7..a4496b0 100644 --- a/config/mail.php +++ b/config/mail.php @@ -118,4 +118,20 @@ return [ 'sendmail' => '', + /* + |-------------------------------------------------------------------------- + | Markdown Mail Settings + |-------------------------------------------------------------------------- + | + | If you are using Markdown based email rendering, you may configure your + | theme and component paths here, allowing you to customize the design + | of the emails. Or, you may simply stick with the Laravel defaults! + | + */ + 'markdown' => [ + 'theme' => 'default', + 'paths' => [ + resource_path('views/vendor/mail'), + ], + ], ]; diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php index 2d5e15e..adb127f 100644 --- a/resources/lang/en/forms.php +++ b/resources/lang/en/forms.php @@ -1,5 +1,6 @@ 'Activate your account', 'activate_user_label' => 'Manually activate this account', 'admin_user_label' => 'User is an administrator', 'album_label' => 'Album:', diff --git a/resources/views/themes/base/email/test_email.blade.php b/resources/views/themes/base/email/test_email.blade.php index d380c32..3b833b8 100644 --- a/resources/views/themes/base/email/test_email.blade.php +++ b/resources/views/themes/base/email/test_email.blade.php @@ -1,9 +1,9 @@ -@extends('themes.base.email_layout') +@component('mail::message') +Hi {{ Auth::user()->name }}, -@section('title', $subject) -@section('content') -

Hi {{ Auth::user()->name }},

-

This e-mail confirms your e-mail settings are correct.

-

You can now press "Save Settings" on the Settings screen to save these settings.

-

Regards,
{{ UserConfig::get('app_name') }}

-@endsection \ No newline at end of file +This e-mail confirms your e-mail settings are correct.
+You can now press "Save Settings" on the Settings screen to save these settings. + +Regards,
+{{ UserConfig::get('app_name') }} +@endcomponent \ No newline at end of file diff --git a/resources/views/themes/base/email/user_activation_required.blade.php b/resources/views/themes/base/email/user_activation_required.blade.php index 9ae4383..b497d08 100644 --- a/resources/views/themes/base/email/user_activation_required.blade.php +++ b/resources/views/themes/base/email/user_activation_required.blade.php @@ -1,15 +1,17 @@ -@extends('themes.base.email_layout') +@component('mail::message') +@lang('email.generic_intro', ['user_name' => $user->name]) -@section('title', $subject) -@section('content') -

@lang('email.generic_intro', ['user_name' => $user->name])

-

@lang('email.activation_required_p1', ['app_name' => UserConfig::get('app_name')])

-

@lang('email.activation_required_p2')

-

{{ route('auth.activate', ['token' => $user->activation_token]) }}

-

- --
- @lang('email.generic_regards')
- {{ UserConfig::get('app_name') }}
- {{ route('home') }} -

-@endsection \ No newline at end of file + +@lang('email.activation_required_p1', ['app_name' => UserConfig::get('app_name')]) + + +@lang('email.activation_required_p2') + +@component('mail::button', ['url' => route('auth.activate', ['token' => $user->activation_token]), 'color' => 'green']) + @lang('forms.activate_action') +@endcomponent + +@lang('email.generic_regards')
+{{ UserConfig::get('app_name') }}
+{{ route('home') }} +@endcomponent \ No newline at end of file diff --git a/resources/views/themes/base/partials/register.blade.php b/resources/views/themes/base/partials/register.blade.php index 3d26e04..a2198f4 100644 --- a/resources/views/themes/base/partials/register.blade.php +++ b/resources/views/themes/base/partials/register.blade.php @@ -1,56 +1,56 @@
{{ csrf_field() }} -
+
- + @if ($errors->has('name')) -
-
+
- + @if ($errors->has('email')) -
-
+
- + @if ($errors->has('password')) -
-
+
- + @if ($errors->has('password_confirmation')) -