added email template, mail api and mail utility class, tweak to Mailer.js
This commit is contained in:
parent
89f84499b2
commit
bedb6fdfe5
6 changed files with 162 additions and 4 deletions
|
@ -18,6 +18,7 @@ include "../brain/utility/DocTools.inc.php";
|
||||||
include "../brain/utility/Sorting.inc.php";
|
include "../brain/utility/Sorting.inc.php";
|
||||||
include "../brain/utility/Setup.inc.php";
|
include "../brain/utility/Setup.inc.php";
|
||||||
include "../brain/utility/Maintenance.inc.php";
|
include "../brain/utility/Maintenance.inc.php";
|
||||||
|
include "../brain/utility/Mailer.inc.php";
|
||||||
|
|
||||||
class App
|
class App
|
||||||
{
|
{
|
||||||
|
|
15
brain/api/v1/MailerAPI.inc.php
Normal file
15
brain/api/v1/MailerAPI.inc.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class MailerAPI
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function handleMail($request, $body, $response)
|
||||||
|
{
|
||||||
|
$result = Mailer::sendmail($request, $body, $response);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ include "../brain/api/v1/ImagesAPI.inc.php";
|
||||||
include "../brain/api/v1/PagesAPI.inc.php";
|
include "../brain/api/v1/PagesAPI.inc.php";
|
||||||
include "../brain/api/v1/SettingsAPI.inc.php";
|
include "../brain/api/v1/SettingsAPI.inc.php";
|
||||||
include "../brain/api/v1/InitAPI.inc.php";
|
include "../brain/api/v1/InitAPI.inc.php";
|
||||||
|
include "../brain/api/v1/MailerAPI.inc.php";
|
||||||
|
|
||||||
class APIControl
|
class APIControl
|
||||||
{
|
{
|
||||||
|
@ -137,6 +138,9 @@ class APIControl
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "mailer":
|
||||||
|
$result = MailerAPI::handleMail($request, $body, $response);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$result = [
|
$result = [
|
||||||
"message" => "Oh, nothing to do. That's unfortunate",
|
"message" => "Oh, nothing to do. That's unfortunate",
|
||||||
|
|
19
brain/utility/Mailer.inc.php
Normal file
19
brain/utility/Mailer.inc.php
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
use Slim\Views\Twig;
|
||||||
|
|
||||||
|
class Mailer
|
||||||
|
{
|
||||||
|
public static function sendMail($request, $body, $response)
|
||||||
|
{
|
||||||
|
$view = Twig::fromRequest($request);
|
||||||
|
|
||||||
|
$render = $view->render($response, "dash/email.twig", [
|
||||||
|
"title" => "EMAIL TESTER",
|
||||||
|
"header" => "Snarky Descriptor",
|
||||||
|
"content" => $body["content"],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$email = $render->getBody()->getContents();
|
||||||
|
echo $email;
|
||||||
|
}
|
||||||
|
}
|
120
brain/views/dash/email.twig
Normal file
120
brain/views/dash/email.twig
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
|
||||||
|
<meta name='viewport' content='width=device-width, initial-scale=1.0' />
|
||||||
|
<title>
|
||||||
|
{{title}}
|
||||||
|
</title>
|
||||||
|
<style type="text/css">
|
||||||
|
/* reset */
|
||||||
|
#outlook a {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
/* Force Outlook to provide a "view in browser" menu link. */
|
||||||
|
.ExternalClass {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
/* Force Hotmail to display emails at full width */
|
||||||
|
.ExternalClass,
|
||||||
|
.ExternalClass p,
|
||||||
|
.ExternalClass span,
|
||||||
|
.ExternalClass font,
|
||||||
|
.ExternalClass td,
|
||||||
|
.ExternalClass div {
|
||||||
|
line-height: 100%;
|
||||||
|
}
|
||||||
|
/* Forces Hotmail to display normal line spacing. More on that: http://www.emailonacid.com/forum/viewthread/43/ */
|
||||||
|
p {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-size: 0px;
|
||||||
|
line-height: 0px;
|
||||||
|
}
|
||||||
|
/* squash Exact Target injected paragraphs */
|
||||||
|
table td {
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
/* Outlook 07, 10 padding issue fix */
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
mso-table-lspace: 0pt;
|
||||||
|
mso-table-rspace: 0pt;
|
||||||
|
}
|
||||||
|
/* remove spacing around Outlook 07, 10 tables */
|
||||||
|
/* bring inline */
|
||||||
|
img {
|
||||||
|
display: block;
|
||||||
|
outline: none;
|
||||||
|
text-decoration: none;
|
||||||
|
-ms-interpolation-mode: bicubic;
|
||||||
|
}
|
||||||
|
a img {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #000001;
|
||||||
|
}
|
||||||
|
/* text link */
|
||||||
|
a.phone {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #000001 !important;
|
||||||
|
pointer-events: auto;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
/* phone link, use as wrapper on phone numbers */
|
||||||
|
span {
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 17px;
|
||||||
|
font-family: monospace;
|
||||||
|
color: #000001;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table cellpadding='0' cellspacing='0' border='0' style="margin:0; padding:0; width:100%; line-height: 100% !important;">
|
||||||
|
<tr>
|
||||||
|
<td valign='top'>
|
||||||
|
{# edge wrapper #}
|
||||||
|
<table cellpadding='0' cellspacing='0' border='0' align='center' width='600' style='background: #374857;'>
|
||||||
|
<tr>
|
||||||
|
<td valign='top' style='vertical-align: top;')>
|
||||||
|
{# info table start #}
|
||||||
|
<table cellpadding='0' cellspacing='0' border='0' align='center' style='width:100%'>
|
||||||
|
<tr>
|
||||||
|
<td valign='top' style='vertical-align: top;text-align: center; padding: 10px'>
|
||||||
|
<span style='font-family: Arial,Helvetica Neue,Helvetica,sans-serif; color:#f5ab35; font-size:20px; font-weight: bold;'>
|
||||||
|
{{ header }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign='top' style='vertical-align: top; background: #161d23; padding:10px;'>
|
||||||
|
<span style='font-family: Arial,Helvetica Neue,Helvetica,sans-serif; color:#cecece; font-size:16px;'>
|
||||||
|
{{ content }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign='top' style='vertical-align: top; padding: 10px;'>
|
||||||
|
<span style='font-family: Arial,Helvetica Neue,Helvetica,sans-serif; color:#b2cce5; font-size:12px;'>
|
||||||
|
{{ footer }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
{# info table end #}
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -5,9 +5,7 @@ export default class Mailer {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor() {
|
constructor() {}
|
||||||
this.admin = new FipamoAdminAPI();
|
|
||||||
}
|
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// methods
|
// methods
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
@ -15,7 +13,8 @@ export default class Mailer {
|
||||||
let mailData = {
|
let mailData = {
|
||||||
content: "This is a test email",
|
content: "This is a test email",
|
||||||
};
|
};
|
||||||
this.admin
|
let admin = new FipamoAdminAPI();
|
||||||
|
admin
|
||||||
.sendMail(mailData)
|
.sendMail(mailData)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
notify.alert(result.message, true);
|
notify.alert(result.message, true);
|
||||||
|
|
Loading…
Reference in a new issue