Add password reset email template
This commit is contained in:
parent
435d893b4e
commit
f40c3e31b5
3 changed files with 76 additions and 4 deletions
|
@ -12,6 +12,8 @@
|
|||
|
||||
namespace wishthis;
|
||||
|
||||
use Qferrer\Mjml\Renderer\ApiRenderer;
|
||||
|
||||
class Email
|
||||
{
|
||||
public function __construct(
|
||||
|
@ -23,9 +25,17 @@ class Email
|
|||
|
||||
public function send()
|
||||
{
|
||||
global $options;
|
||||
|
||||
$renderer = new ApiRenderer(
|
||||
$options->getOption('mjml_api_key'),
|
||||
$options->getOption('mjml_api_secret')
|
||||
);
|
||||
$html = $renderer->render($this->mjml);
|
||||
|
||||
$to = $this->to;
|
||||
$subject = $this->subject;
|
||||
$message = $this->mjml;
|
||||
$message = $html;
|
||||
$headers = array(
|
||||
'From' => 'no-reply@' . $_SERVER['HTTP_HOST'],
|
||||
'Content-type' => 'text/html; charset=utf-8',
|
||||
|
|
58
src/mjml/password-reset.mjml
Normal file
58
src/mjml/password-reset.mjml
Normal file
|
@ -0,0 +1,58 @@
|
|||
<mjml>
|
||||
<mj-head>
|
||||
<mj-attributes>
|
||||
<mj-all font-family="Raleway, sans-serif"
|
||||
font-size="12pt"
|
||||
/>
|
||||
<mj-body background-color="#f4f4f4" />
|
||||
<mj-text line-height="1.6" />
|
||||
<mj-button align="left"
|
||||
background-color="#6435c9"
|
||||
font-weight="700"
|
||||
/>
|
||||
|
||||
<mj-class name="segment"
|
||||
background-color="#fff"
|
||||
border="1px solid rgba(34,36,38,.15)"
|
||||
/>
|
||||
</mj-attributes>
|
||||
|
||||
<mj-font name="Raleway" href="https://fonts.googleapis.com/css?family=Raleway" />
|
||||
|
||||
<mj-style>
|
||||
a {
|
||||
color: #6435c9;
|
||||
}
|
||||
.segment {
|
||||
box-shadow: 0 1px 2px 0 rgba(34,36,38,.15);
|
||||
}
|
||||
</mj-style>
|
||||
</mj-head>
|
||||
<mj-body>
|
||||
<mj-section>
|
||||
<mj-column>
|
||||
</mj-column>
|
||||
</mj-section>
|
||||
|
||||
<mj-section>
|
||||
<mj-column>
|
||||
<mj-image src="https://wishthis.online/src/assets/img/logo.svg"
|
||||
height="28px"
|
||||
align="left"
|
||||
/>
|
||||
</mj-column>
|
||||
</mj-section>
|
||||
|
||||
<mj-section mj-class="segment" css-class="segment">
|
||||
<mj-column>
|
||||
|
||||
<mj-text>Hello,</mj-text>
|
||||
|
||||
<mj-text>somebody has requested a password reset for this email address from <a href="https://wishthis.online">wishthis.online</a>. If this was you, click the button below to invalidate your current password and set a new one.</mj-text>
|
||||
|
||||
<mj-button href="#">Set new password</mj-button>
|
||||
|
||||
</mj-column>
|
||||
</mj-section>
|
||||
</mj-body>
|
||||
</mjml>
|
|
@ -6,7 +6,7 @@
|
|||
* @author Jay Trees <github.jay@grandel.anonaddy.me>
|
||||
*/
|
||||
|
||||
use wishthis\Page;
|
||||
use wishthis\{Page, Email};
|
||||
|
||||
$page = new Page(__FILE__, 'Login');
|
||||
|
||||
|
@ -46,11 +46,15 @@ if (isset($_POST['reset'], $_POST['email'])) {
|
|||
$user = $database
|
||||
->query('SELECT *
|
||||
FROM `users`
|
||||
WHERE `email` = ' . $_POST['email'] . ';')
|
||||
WHERE `email` = "' . $_POST['email'] . '";')
|
||||
->fetch();
|
||||
|
||||
if ($user) {
|
||||
$emailReset = new email($_POST['email']);
|
||||
$mjml = file_get_contents(ROOT . '/src/mjml/password-reset.mjml');
|
||||
$mjml = str_replace('https://wishthis.online', $_SERVER['HTTP_HOST'], $mjml);
|
||||
|
||||
$emailReset = new Email($_POST['email'], 'Password reset link', $mjml);
|
||||
$emailReset->send();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue