Fix email design
This commit is contained in:
parent
53552e7008
commit
28a449e513
9 changed files with 97 additions and 114 deletions
|
@ -58,35 +58,34 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
||||||
$href = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . Page::PAGE_WISHLISTS . '&id=' . $wishlist['id'];
|
$href = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . Page::PAGE_WISHLISTS . '&id=' . $wishlist['id'];
|
||||||
|
|
||||||
/** Send email */
|
/** Send email */
|
||||||
$mjml = file_get_contents(ROOT . '/src/mjml/wishlist-request-wishes.mjml');
|
$user = new User($wishlist['user']);
|
||||||
$mjml = str_replace(
|
$email = new Email($user->email, __('Wish request'), 'default', 'wishlist-request-wishes');
|
||||||
|
$email->mjml = str_replace(
|
||||||
'TEXT_HELLO',
|
'TEXT_HELLO',
|
||||||
__('Hello,'),
|
__('Hello,'),
|
||||||
$mjml
|
$email->mjml
|
||||||
);
|
);
|
||||||
$mjml = str_replace(
|
$email->mjml = str_replace(
|
||||||
'TEXT_WISHLIST_REQUEST_WISHES',
|
'TEXT_WISHLIST_REQUEST_WISHES',
|
||||||
sprintf(
|
sprintf(
|
||||||
/** TRANSLATORS: %s: Wishlist name */
|
/** TRANSLATORS: %s: Wishlist name */
|
||||||
__('somebody has requested that you add more wishes to your wishlist %s.'),
|
__('somebody has requested that you add more wishes to your wishlist %s.'),
|
||||||
'<a href="' . $href . '">' . $wishlist['name'] . '</a>'
|
'<a href="' . $href . '">' . $wishlist['name'] . '</a>'
|
||||||
),
|
),
|
||||||
$mjml
|
$email->mjml
|
||||||
);
|
);
|
||||||
$mjml = str_replace(
|
$email->mjml = str_replace(
|
||||||
'TEXT_WISH_ADD',
|
'TEXT_WISH_ADD',
|
||||||
__('Add wish'),
|
__('Add wish'),
|
||||||
$mjml
|
$email->mjml
|
||||||
);
|
);
|
||||||
$mjml = str_replace(
|
$email->mjml = str_replace(
|
||||||
'LINK_WISH_ADD',
|
'LINK_WISH_ADD',
|
||||||
$href . '&wish_add=true',
|
$href . '&wish_add=true',
|
||||||
$mjml
|
$email->mjml
|
||||||
);
|
);
|
||||||
|
|
||||||
$user = new User($wishlist['user']);
|
$success = $email->send();
|
||||||
$emailRequest = new Email($user->email, __('Wish request'), $mjml);
|
|
||||||
$success = $emailRequest->send();
|
|
||||||
|
|
||||||
/** Save date to database */
|
/** Save date to database */
|
||||||
if (true === $success) {
|
if (true === $success) {
|
||||||
|
|
|
@ -16,11 +16,16 @@ use Qferrer\Mjml\Renderer\ApiRenderer;
|
||||||
|
|
||||||
class Email
|
class Email
|
||||||
{
|
{
|
||||||
|
public string $mjml;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private string $to,
|
private string $to,
|
||||||
private string $subject,
|
private string $subject,
|
||||||
private string $mjml
|
private string $template,
|
||||||
|
private string $part
|
||||||
) {
|
) {
|
||||||
|
$this->mjml = file_get_contents(ROOT . '/src/mjml/' . $this->template . '.mjml');
|
||||||
|
$this->mjml = str_replace('MJML_PART', 'parts/' . $this->part . '.mjml');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function send(): bool
|
public function send(): bool
|
||||||
|
|
49
src/mjml/default.mjml
Normal file
49
src/mjml/default.mjml
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<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"
|
||||||
|
alt="wishthis"
|
||||||
|
height="28px"
|
||||||
|
align="left"
|
||||||
|
/>
|
||||||
|
</mj-column>
|
||||||
|
</mj-section>
|
||||||
|
|
||||||
|
<mj-include path="MJML_PART" />
|
||||||
|
|
||||||
|
<mj-section><mj-column></mj-column></mj-section>
|
||||||
|
</mj-body>
|
||||||
|
</mjml>
|
|
@ -1,27 +0,0 @@
|
||||||
<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>
|
|
11
src/mjml/parts/password-reset.mjml
Normal file
11
src/mjml/parts/password-reset.mjml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<mj-section mj-class="segment" css-class="segment">
|
||||||
|
<mj-column>
|
||||||
|
|
||||||
|
<mj-text>TEXT_HELLO</mj-text>
|
||||||
|
|
||||||
|
<mj-text>TEXT_PASSWORD_RESET</mj-text>
|
||||||
|
|
||||||
|
<mj-button href="password-reset-link">TEXT_SET_NEW_PASSWORD</mj-button>
|
||||||
|
|
||||||
|
</mj-column>
|
||||||
|
</mj-section>
|
11
src/mjml/parts/wishlist-request-wishes.mjml
Normal file
11
src/mjml/parts/wishlist-request-wishes.mjml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<mj-section mj-class="segment" css-class="segment">
|
||||||
|
<mj-column>
|
||||||
|
|
||||||
|
<mj-text>TEXT_HELLO</mj-text>
|
||||||
|
|
||||||
|
<mj-text>TEXT_WISHLIST_REQUEST_WISHES</mj-text>
|
||||||
|
|
||||||
|
<mj-button href="LINK_WISH_ADD">TEXT_WISH_ADD</mj-button>
|
||||||
|
|
||||||
|
</mj-column>
|
||||||
|
</mj-section>
|
|
@ -1,32 +0,0 @@
|
||||||
<mjml>
|
|
||||||
<mj-head>
|
|
||||||
<mj-include path="parts/head.mjml" />
|
|
||||||
</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"
|
|
||||||
alt="wishthis"
|
|
||||||
height="28px"
|
|
||||||
align="left"
|
|
||||||
/>
|
|
||||||
</mj-column>
|
|
||||||
</mj-section>
|
|
||||||
|
|
||||||
<mj-section mj-class="segment" css-class="segment">
|
|
||||||
<mj-column>
|
|
||||||
|
|
||||||
<mj-text>TEXT_HELLO</mj-text>
|
|
||||||
|
|
||||||
<mj-text>TEXT_PASSWORD_RESET</mj-text>
|
|
||||||
|
|
||||||
<mj-button href="password-reset-link">TEXT_SET_NEW_PASSWORD</mj-button>
|
|
||||||
|
|
||||||
</mj-column>
|
|
||||||
</mj-section>
|
|
||||||
|
|
||||||
<mj-section><mj-column></mj-column></mj-section>
|
|
||||||
</mj-body>
|
|
||||||
</mjml>
|
|
|
@ -1,32 +0,0 @@
|
||||||
<mjml>
|
|
||||||
<mj-head>
|
|
||||||
<mj-include path="parts/head.mjml" />
|
|
||||||
</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"
|
|
||||||
alt="wishthis"
|
|
||||||
height="28px"
|
|
||||||
align="left"
|
|
||||||
/>
|
|
||||||
</mj-column>
|
|
||||||
</mj-section>
|
|
||||||
|
|
||||||
<mj-section mj-class="segment" css-class="segment">
|
|
||||||
<mj-column>
|
|
||||||
|
|
||||||
<mj-text>TEXT_HELLO</mj-text>
|
|
||||||
|
|
||||||
<mj-text>TEXT_WISHLIST_REQUEST_WISHES</mj-text>
|
|
||||||
|
|
||||||
<mj-button href="LINK_WISH_ADD">TEXT_WISH_ADD</mj-button>
|
|
||||||
|
|
||||||
</mj-column>
|
|
||||||
</mj-section>
|
|
||||||
|
|
||||||
<mj-section><mj-column></mj-column></mj-section>
|
|
||||||
</mj-body>
|
|
||||||
</mjml>
|
|
|
@ -68,28 +68,28 @@ if (isset($_POST['reset'], $_POST['email'])) {
|
||||||
WHERE `id` = ' . $user['id'] . '
|
WHERE `id` = ' . $user['id'] . '
|
||||||
;');
|
;');
|
||||||
|
|
||||||
$mjml = file_get_contents(ROOT . '/src/mjml/password-reset.mjml');
|
$emailReset = new Email($_POST['email'], __('Password reset link'), 'default', 'password-reset');
|
||||||
$mjml = str_replace(
|
$emailReset->mjml = str_replace(
|
||||||
'TEXT_HELLO',
|
'TEXT_HELLO',
|
||||||
__('Hello,'),
|
__('Hello,'),
|
||||||
$mjml
|
$emailReset->mjml
|
||||||
);
|
);
|
||||||
$mjml = str_replace(
|
$emailReset->mjml = str_replace(
|
||||||
'TEXT_PASSWORD_RESET',
|
'TEXT_PASSWORD_RESET',
|
||||||
__('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.'),
|
__('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.'),
|
||||||
$mjml
|
$emailReset->mjml
|
||||||
);
|
);
|
||||||
$mjml = str_replace(
|
$emailReset->mjml = str_replace(
|
||||||
'TEXT_SET_NEW_PASSWORD',
|
'TEXT_SET_NEW_PASSWORD',
|
||||||
__('Set new password'),
|
__('Set new password'),
|
||||||
$mjml
|
$emailReset->mjml
|
||||||
);
|
);
|
||||||
$mjml = str_replace(
|
$emailReset->mjml = str_replace(
|
||||||
'wishthis.online',
|
'wishthis.online',
|
||||||
$_SERVER['HTTP_HOST'],
|
$_SERVER['HTTP_HOST'],
|
||||||
$mjml
|
$mjml
|
||||||
);
|
);
|
||||||
$mjml = str_replace(
|
$emailReset->mjml = str_replace(
|
||||||
'password-reset-link',
|
'password-reset-link',
|
||||||
$_SERVER['REQUEST_SCHEME'] . '://' .
|
$_SERVER['REQUEST_SCHEME'] . '://' .
|
||||||
$_SERVER['HTTP_HOST'] .
|
$_SERVER['HTTP_HOST'] .
|
||||||
|
@ -97,7 +97,6 @@ if (isset($_POST['reset'], $_POST['email'])) {
|
||||||
$mjml
|
$mjml
|
||||||
);
|
);
|
||||||
|
|
||||||
$emailReset = new Email($_POST['email'], __('Password reset link'), $mjml);
|
|
||||||
$emailReset->send();
|
$emailReset->send();
|
||||||
|
|
||||||
$page->messages[] = Page::info(
|
$page->messages[] = Page::info(
|
||||||
|
|
Loading…
Reference in a new issue