diff --git a/app/Http/Controllers/API/MailAPIController.php b/app/Http/Controllers/API/MailAPIController.php new file mode 100644 index 0000000..cbee19f --- /dev/null +++ b/app/Http/Controllers/API/MailAPIController.php @@ -0,0 +1,35 @@ +send(new SystemEmail($request->content)); + $result = [ + 'type' => 'mail_good', + 'message' => 'Mail Sent', + ]; + } catch (ERROR $e) { + $result = [ + 'type' => 'mail_not_good', + 'message' => 'Mail Not Sent', + ]; + } + + return response()->json($result)->header('Content-Type', 'application/json'); + } +} diff --git a/app/Http/Controllers/SystemMailController.php b/app/Http/Controllers/SystemMailController.php new file mode 100644 index 0000000..ccfaeed --- /dev/null +++ b/app/Http/Controllers/SystemMailController.php @@ -0,0 +1,17 @@ +send(new SystemEmail($message)); + } +} diff --git a/app/Mail/SystemEmail.php b/app/Mail/SystemEmail.php new file mode 100644 index 0000000..8b093a2 --- /dev/null +++ b/app/Mail/SystemEmail.php @@ -0,0 +1,55 @@ + + */ + public function attachments(): array + { + return []; + } +} diff --git a/app/Services/Data/SortingService.php b/app/Services/Data/SortingService.php index b071d8e..d8a3100 100644 --- a/app/Services/Data/SortingService.php +++ b/app/Services/Data/SortingService.php @@ -265,7 +265,6 @@ class SortingService public function settings() { $global = $this->settings->getGlobal(); - $email = $this->settings->getEmail(); $updated = new Carbon($global['last_backup']); $status = session('member') != '' ? true : false; $pageOptions = [ @@ -283,8 +282,6 @@ class SortingService 'themes' => $this->themes->getThemes(), 'apiStatus' => isset($global['externalAPI']) ? $global['externalAPI'] : 'false', 'dynamicRenderStatus' => isset($global['dynamicRender']) ? $global['dynamicRender'] : 'false', - 'mailOption' => $email['active'], - 'mailConfig' => $email, 'status' => $status, ]; return $pageOptions; diff --git a/content/init/settings-template.json b/content/init/settings-template.json index b4dcc82..6f648af 100644 --- a/content/init/settings-template.json +++ b/content/init/settings-template.json @@ -15,17 +15,5 @@ "library_stats": { "current_index": 1 }, - "email": { - "active": "none", - "smtp": { - "domain": "", - "email": "", - "password": "" - }, - "mailgun": { - "domain": "", - "api-key": "" - } - }, "menu": [] } diff --git a/public/assets/css/dash/settings.css b/public/assets/css/dash/settings.css index 1ed95f2..69dedc0 100644 --- a/public/assets/css/dash/settings.css +++ b/public/assets/css/dash/settings.css @@ -149,6 +149,7 @@ section#site-features > div.features-mail { border-radius: 3px; background: var(--secondary); padding: 10px; + color: var(--primary); } section#site-features > div.features-mail input { diff --git a/public/assets/scripts/dash/app/actions/Mailer.js b/public/assets/scripts/dash/app/actions/Mailer.js index d099153..cd04234 100644 --- a/public/assets/scripts/dash/app/actions/Mailer.js +++ b/public/assets/scripts/dash/app/actions/Mailer.js @@ -9,24 +9,16 @@ export default class Mailer { //-------------------------- // methods //-------------------------- - sendMail() { + sendMail(task = null, content = null) { + let text = ''; + if (task == 'TEST') { + text = 'This is a test email'; + } else { + text = content; + } let mailData = { - content: 'This is a test email' - }; - let admin = new FipamoAdminAPI(); - admin - .sendMail(mailData) - .then(result => { - notify.alert(result.message, true); - }) - .catch(err => { - notify.alert(err.message, false); - }); - } - testMail() { - let mailData = { - content: 'This is a test email', - mail_task: 'TESTING' + content: text, + mail_task: task }; let admin = new FipamoAdminAPI(); admin diff --git a/public/assets/scripts/dash/app/controllers/SettingsIndex.js b/public/assets/scripts/dash/app/controllers/SettingsIndex.js index 5e7f0fe..9db189e 100644 --- a/public/assets/scripts/dash/app/controllers/SettingsIndex.js +++ b/public/assets/scripts/dash/app/controllers/SettingsIndex.js @@ -110,8 +110,8 @@ export default class SettingsIndex { } document - .getElementById('send-mail') - .addEventListener('click', e => this.handleMailer(e)); + .getElementById('send-test-mail') + .addEventListener('click', e => this.handleTestMail(e)); document .getElementById('publish-pages') .addEventListener('click', e => this.handlePublished(e)); @@ -160,10 +160,10 @@ export default class SettingsIndex { //e.target.innerHTML = "DON'T RENDER PAGES ON SAVE"; } } - handleMailer() { + handleTestMail() { let mailer = new Mailer(); - mailer.testMail(); - //mailer.sendMail(); + //mailer.testMail(); + mailer.sendMail('TEST'); } handleThemes(e) { e.stopPropagation(); @@ -185,30 +185,6 @@ export default class SettingsIndex { } } } - handleMailOptions(e) { - e.preventDefault(); - e.stopPropagation(); - let smtp = document.getElementById('mail-smtp'); - let mailgun = document.getElementById('mail-mg'); - let mail = document.querySelectorAll('.mail-option'); - for (var i = 0, length = mail.length; i < length; i++) { - if (e.target.id == mail[i].id) { - mail[i].setAttribute('data-enabled', 'true'); - if (e.target.id == 'option-smtp') { - smtp.setAttribute('data-enabled', 'true'); - mailgun.setAttribute('data-enabled', 'false'); - } else if (e.target.id == 'option-none') { - smtp.setAttribute('data-enabled', 'false'); - mailgun.setAttribute('data-enabled', 'false'); - } else { - smtp.setAttribute('data-enabled', 'false'); - mailgun.setAttribute('data-enabled', 'true'); - } - } else { - mail[i].setAttribute('data-enabled', 'false'); - } - } - } handleImageUpload(type, files) { notify.alert('Uploading Image... ', null); let self = this; diff --git a/resources/views/back/settings.blade.php b/resources/views/back/settings.blade.php index 19783fc..1248266 100644 --- a/resources/views/back/settings.blade.php +++ b/resources/views/back/settings.blade.php @@ -45,32 +45,16 @@
- -
- @if($mailOption == "option-none" or $mailOption == "") - NONE - @else - NONE - @endif - @if($mailOption == "option-mg" or $mailOption == "") - MAILGUN - @else - MAILGUN - @endif - @if($mailOption == "option-smtp" or $mailOption == "") - SMTP - @else - SMTP - @endif -
- - @include('forms.mailforms') - +
+
+ set email settings in .env file +
diff --git a/resources/views/mail/notify.blade.php b/resources/views/mail/notify.blade.php new file mode 100644 index 0000000..c603ae0 --- /dev/null +++ b/resources/views/mail/notify.blade.php @@ -0,0 +1,4 @@ +
+ NOTICE
+ {{$notifyText}}
+
diff --git a/routes/api.php b/routes/api.php index d79a31a..6b9e2f8 100644 --- a/routes/api.php +++ b/routes/api.php @@ -6,6 +6,7 @@ use App\Http\Controllers\API\PageAPIController; use App\Http\Controllers\API\FileUploadAPIController; use App\Http\Controllers\API\SettingsAPIController; use App\Http\Controllers\API\InitAPIController; +use App\Http\Controllers\API\MailAPIController; /* |-------------------------------------------------------------------------- @@ -34,3 +35,5 @@ Route::get("/v1/backup/download", [SettingsAPIController::class, 'downloadBackup //init Route::post("/v1/init", [InitAPIController::class, 'setupFresh']); Route::post("/v1/restore", [InitAPIController::class, 'setupRestore']); +//mail +Route::post("/v1/mailer", [MailAPIController::class, 'sendNotify']);