Skip to content

Commit

Permalink
Merge pull request #208 from Divyesh000/emailtemplate
Browse files Browse the repository at this point in the history
email template for password reset email
  • Loading branch information
creme332 authored May 24, 2024
2 parents 7188fbc + afd6f14 commit 254c21a
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/controllers/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,19 @@ public function __construct()
*/
private function sendResetEmail(string $email, string $resetLink): void
{
//Implement logic to send reset email using Mailer class
$mailer = new Mailer();
$subject = "Reset Your Password | Steamy Sips";
$htmlMessage = "Click the link below to reset your password:<br><a href='$resetLink'>$resetLink</a>";

// Capture the HTML template content
ob_start();
$userEmail = $email;
require __DIR__ . '/../views/mails/PasswordReset.php';
$htmlMessage = ob_get_clean();

// Plain message as fallback
$plainMessage = "Click the link below to reset your password:\n$resetLink";

// Send the email
$mailer = new Mailer();
$mailer->sendMail($email, $subject, $htmlMessage, $plainMessage);
}

Expand Down
98 changes: 98 additions & 0 deletions src/views/mails/PasswordReset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

declare(strict_types=1);

/**
* This file contains the template for the password reset email.
* It will be used by the sendResetEmail method in the Password controller.
*
* @var string $resetLink The link to reset the password.
* @var string $userEmail The email of the user receiving the reset link.
*/

?>

<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Reset Your Password</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f7f7f7;
color: #333;
line-height: 1.6;
margin: 0;
padding: 0;
}

.container {
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border: 1px solid #ddd;
}

.header {
text-align: center;
padding: 10px 0;
border-bottom: 1px solid #ddd;
}

.header img {
max-width: 100px;
}

.content {
padding: 20px;
}

.footer {
text-align: center;
padding: 10px 0;
border-top: 1px solid #ddd;
font-size: 0.9em;
color: #999;
}

.button {
display: inline-block;
padding: 10px 20px;
margin: 20px 0;
font-size: 16px;
color: #fff;
background-color: #007bff;
text-decoration: none;
border-radius: 5px;
}

.button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<img src="cid:logo" alt="Steamy Sips Logo">
</div>
<div class="content">
<h1>Reset Your Password</h1>
<p>Hello,</p>
<p>We received a request to reset the password for the account associated with <?= htmlspecialchars(
$userEmail
) ?>. Click the button below to reset your password:</p>
<p><a href="<?= htmlspecialchars($resetLink) ?>" class="button">Reset My Password</a></p>
<p>If you did not request a password reset, please ignore this email. This link will expire in 24 hours.</p>
<p>Thank you,<br>The Steamy Sips Team</p>
</div>
<div class="footer">
<p>&copy; <?= date('Y') ?> Steamy Sips. All rights reserved.</p>
</div>
</div>
</body>
</html>

0 comments on commit 254c21a

Please sign in to comment.