]> BookStack Code Mirror - bookstack/commitdiff
Add feature to send test e-mails 1719/head
authorTimo Schwarzer <redacted>
Tue, 15 Oct 2019 16:41:08 +0000 (18:41 +0200)
committerTimo Schwarzer <redacted>
Wed, 16 Oct 2019 06:24:33 +0000 (08:24 +0200)
app/Http/Controllers/SettingController.php
app/Notifications/TestEmail.php [new file with mode: 0644]
resources/lang/en/settings.php
resources/views/settings/maintenance.blade.php
routes/web.php

index 1146f22c749ec8df442dfe6a278b3922a3a1fdea..f0a078300654861de6026ccf5ce9929f456976a0 100644 (file)
@@ -1,6 +1,7 @@
 <?php namespace BookStack\Http\Controllers;
 
 use BookStack\Auth\User;
 <?php namespace BookStack\Http\Controllers;
 
 use BookStack\Auth\User;
+use BookStack\Notifications\TestEmail;
 use BookStack\Uploads\ImageRepo;
 use BookStack\Uploads\ImageService;
 use Illuminate\Http\Request;
 use BookStack\Uploads\ImageRepo;
 use BookStack\Uploads\ImageService;
 use Illuminate\Http\Request;
@@ -123,4 +124,20 @@ class SettingController extends Controller
 
         return redirect('/settings/maintenance#image-cleanup')->withInput();
     }
 
         return redirect('/settings/maintenance#image-cleanup')->withInput();
     }
+
+    /**
+     * Action to send a test e-mail to the current user.
+     * @param Request $request
+     * @param User $user
+     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+     */
+    public function sendTestEmail(Request $request)
+    {
+        $this->checkPermission('settings-manage');
+
+        user()->notify(new TestEmail());
+        $this->showSuccessNotification(trans('settings.maint_send_test_email_success', ['address' => user()->email]));
+
+        return redirect('/settings/maintenance#image-cleanup')->withInput();
+    }
 }
 }
diff --git a/app/Notifications/TestEmail.php b/app/Notifications/TestEmail.php
new file mode 100644 (file)
index 0000000..7fce1c1
--- /dev/null
@@ -0,0 +1,18 @@
+<?php namespace BookStack\Notifications;
+
+class TestEmail extends MailNotification
+{
+    /**
+     * Get the mail representation of the notification.
+     *
+     * @param  mixed  $notifiable
+     * @return \Illuminate\Notifications\Messages\MailMessage
+     */
+    public function toMail($notifiable)
+    {
+        return $this->newMailMessage()
+                ->subject(trans('settings.maint_send_test_email_mail_subject'))
+                ->greeting(trans('settings.maint_send_test_email_mail_greeting'))
+                ->line(trans('settings.maint_send_test_email_mail_text'));
+    }
+}
index bb542a588895b9cbedc1e2b2900d3883f64869f3..3bcd517ca87acb1434bf9e2e1d772e8b09bbc4e1 100755 (executable)
@@ -63,6 +63,13 @@ return [
     'maint_image_cleanup_warning' => ':count potentially unused images were found. Are you sure you want to delete these images?',
     'maint_image_cleanup_success' => ':count potentially unused images found and deleted!',
     'maint_image_cleanup_nothing_found' => 'No unused images found, Nothing deleted!',
     'maint_image_cleanup_warning' => ':count potentially unused images were found. Are you sure you want to delete these images?',
     'maint_image_cleanup_success' => ':count potentially unused images found and deleted!',
     'maint_image_cleanup_nothing_found' => 'No unused images found, Nothing deleted!',
+    'maint_send_test_email' => 'Send a Test E-Mail',
+    'maint_send_test_email_desc' => 'This sends a test e-mail to your e-mail address specified in your profile.',
+    'maint_send_test_email_run' => 'Send test e-mail',
+    'maint_send_test_email_success' => 'E-Mail sent to :address',
+    'maint_send_test_email_mail_subject' => 'Test E-Mail',
+    'maint_send_test_email_mail_greeting' => 'E-Mail delivery seems to work!',
+    'maint_send_test_email_mail_text' => 'Congratulations! As you received this e-mail notification, your e-mail settings seem to be configured properly.',
 
     // Role Settings
     'roles' => 'Roles',
 
     // Role Settings
     'roles' => 'Roles',
index 6be49cdf2c94479d077ef2258f36bcdd08d1183c..ecd4702a68668be460e1bafd5d74592389eec61f 100644 (file)
@@ -13,7 +13,6 @@
         </div>
     </div>
 
         </div>
     </div>
 
-
     <div id="image-cleanup" class="card content-wrap auto-height">
         <h2 class="list-heading">{{ trans('settings.maint_image_cleanup') }}</h2>
         <div class="grid half gap-xl">
     <div id="image-cleanup" class="card content-wrap auto-height">
         <h2 class="list-heading">{{ trans('settings.maint_image_cleanup') }}</h2>
         <div class="grid half gap-xl">
         </div>
     </div>
 
         </div>
     </div>
 
+    <div id="send-test-email" class="card content-wrap auto-height">
+        <h2 class="list-heading">{{ trans('settings.maint_send_test_email') }}</h2>
+        <div class="grid half gap-xl">
+            <div>
+                <p class="small text-muted">{{ trans('settings.maint_send_test_email_desc') }}</p>
+            </div>
+            <div>
+                <form method="POST" action="{{ url('/settings/maintenance/send-test-email') }}">
+                    {!! csrf_field()  !!}
+                    <button class="button outline">{{ trans('settings.maint_send_test_email_run') }}</button>
+                </form>
+            </div>
+        </div>
+    </div>
+
 </div>
 @stop
 </div>
 @stop
index 5dee447a4c7abd56d67a495dcdd68336ac6b9026..eafb6a45cbc6f91d1881f453439d53902437d218 100644 (file)
@@ -172,6 +172,7 @@ Route::group(['middleware' => 'auth'], function () {
         // Maintenance
         Route::get('/maintenance', 'SettingController@showMaintenance');
         Route::delete('/maintenance/cleanup-images', 'SettingController@cleanupImages');
         // Maintenance
         Route::get('/maintenance', 'SettingController@showMaintenance');
         Route::delete('/maintenance/cleanup-images', 'SettingController@cleanupImages');
+        Route::post('/maintenance/send-test-email', 'SettingController@sendTestEmail');
 
         // Users
         Route::get('/users', 'UserController@index');
 
         // Users
         Route::get('/users', 'UserController@index');