From bedb6fdfe5d47dc301cf858a96ffd9c8fdca88b8 Mon Sep 17 00:00:00 2001 From: Ro Date: Fri, 30 Apr 2021 21:55:23 +0000 Subject: [PATCH] added email template, mail api and mail utility class, tweak to Mailer.js --- brain/App.inc.php | 1 + brain/api/v1/MailerAPI.inc.php | 15 ++++ brain/controller/APIControl.inc.php | 4 + brain/utility/Mailer.inc.php | 19 +++++ brain/views/dash/email.twig | 120 ++++++++++++++++++++++++++++ src/com/actions/Mailer.js | 7 +- 6 files changed, 162 insertions(+), 4 deletions(-) create mode 100644 brain/api/v1/MailerAPI.inc.php create mode 100644 brain/utility/Mailer.inc.php create mode 100644 brain/views/dash/email.twig diff --git a/brain/App.inc.php b/brain/App.inc.php index 33dd18e..53361ff 100644 --- a/brain/App.inc.php +++ b/brain/App.inc.php @@ -18,6 +18,7 @@ include "../brain/utility/DocTools.inc.php"; include "../brain/utility/Sorting.inc.php"; include "../brain/utility/Setup.inc.php"; include "../brain/utility/Maintenance.inc.php"; +include "../brain/utility/Mailer.inc.php"; class App { diff --git a/brain/api/v1/MailerAPI.inc.php b/brain/api/v1/MailerAPI.inc.php new file mode 100644 index 0000000..650f0ca --- /dev/null +++ b/brain/api/v1/MailerAPI.inc.php @@ -0,0 +1,15 @@ + "Oh, nothing to do. That's unfortunate", diff --git a/brain/utility/Mailer.inc.php b/brain/utility/Mailer.inc.php new file mode 100644 index 0000000..35f5d13 --- /dev/null +++ b/brain/utility/Mailer.inc.php @@ -0,0 +1,19 @@ +render($response, "dash/email.twig", [ + "title" => "EMAIL TESTER", + "header" => "Snarky Descriptor", + "content" => $body["content"], + ]); + + $email = $render->getBody()->getContents(); + echo $email; + } +} diff --git a/brain/views/dash/email.twig b/brain/views/dash/email.twig new file mode 100644 index 0000000..0fc58cb --- /dev/null +++ b/brain/views/dash/email.twig @@ -0,0 +1,120 @@ + + + + + + + + {{title}} + + + + + + + + + +
+ {# edge wrapper #} + + + + +
+ {# info table start #} + + + + + + + + + + +
+ + {{ header }} + +
+ + {{ content }} + +
+ + {{ footer }} + +
+ {# info table end #} + +
+ +
+ + \ No newline at end of file diff --git a/src/com/actions/Mailer.js b/src/com/actions/Mailer.js index 486b5cd..4e2fa59 100644 --- a/src/com/actions/Mailer.js +++ b/src/com/actions/Mailer.js @@ -5,9 +5,7 @@ export default class Mailer { //-------------------------- // constructor //-------------------------- - constructor() { - this.admin = new FipamoAdminAPI(); - } + constructor() {} //-------------------------- // methods //-------------------------- @@ -15,7 +13,8 @@ export default class Mailer { let mailData = { content: "This is a test email", }; - this.admin + let admin = new FipamoAdminAPI(); + admin .sendMail(mailData) .then((result) => { notify.alert(result.message, true);