From 2d6e12bfbf48cb59c8ed448734f81e93cab1a9df Mon Sep 17 00:00:00 2001 From: divyesh000 Date: Wed, 22 May 2024 20:42:26 +0400 Subject: [PATCH 1/2] refactore sendResetEmail method to use an HTML template for email content --- src/controllers/Password.php | 22 +++++--- src/views/mails/PasswordReset.php | 89 +++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 src/views/mails/PasswordReset.php diff --git a/src/controllers/Password.php b/src/controllers/Password.php index 4f2298f6..3f0f728d 100644 --- a/src/controllers/Password.php +++ b/src/controllers/Password.php @@ -40,14 +40,22 @@ 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:
$resetLink"; - $plainMessage = "Click the link below to reset your password:\n$resetLink"; - $mailer->sendMail($email, $subject, $htmlMessage, $plainMessage); - } + $subject = "Reset Your Password | Steamy Sips"; + + // 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); + } + /** * Invoked when user submits an email on form. * @throws Exception Email could not be sent diff --git a/src/views/mails/PasswordReset.php b/src/views/mails/PasswordReset.php new file mode 100644 index 00000000..2120f770 --- /dev/null +++ b/src/views/mails/PasswordReset.php @@ -0,0 +1,89 @@ + + + + + + + + Reset Your Password + + + +
+
+ Steamy Sips Logo +
+
+

Reset Your Password

+

Hello,

+

We received a request to reset the password for the account associated with . Click the button below to reset your password:

+

Reset My Password

+

If you did not request a password reset, please ignore this email. This link will expire in 24 hours.

+

Thank you,
The Steamy Sips Team

+
+ +
+ + From afd6f145b21ea602c5fa530d3de9f3ff18288de1 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Fri, 24 May 2024 21:19:16 +0400 Subject: [PATCH 2/2] format files --- src/controllers/Password.php | 24 +++--- src/views/mails/PasswordReset.php | 133 ++++++++++++++++-------------- 2 files changed, 83 insertions(+), 74 deletions(-) diff --git a/src/controllers/Password.php b/src/controllers/Password.php index 3f0f728d..03de1de4 100644 --- a/src/controllers/Password.php +++ b/src/controllers/Password.php @@ -40,22 +40,22 @@ public function __construct() */ private function sendResetEmail(string $email, string $resetLink): void { - $subject = "Reset Your Password | Steamy Sips"; + $subject = "Reset Your Password | Steamy Sips"; - // Capture the HTML template content - ob_start(); - $userEmail = $email; - require __DIR__ . '/../views/mails/PasswordReset.php'; - $htmlMessage = ob_get_clean(); + // 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"; + // 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); + // Send the email + $mailer = new Mailer(); + $mailer->sendMail($email, $subject, $htmlMessage, $plainMessage); } - + /** * Invoked when user submits an email on form. * @throws Exception Email could not be sent diff --git a/src/views/mails/PasswordReset.php b/src/views/mails/PasswordReset.php index 2120f770..9cddb85a 100644 --- a/src/views/mails/PasswordReset.php +++ b/src/views/mails/PasswordReset.php @@ -19,71 +19,80 @@ Reset Your Password -
-
- Steamy Sips Logo -
-
-

Reset Your Password

-

Hello,

-

We received a request to reset the password for the account associated with . Click the button below to reset your password:

-

Reset My Password

-

If you did not request a password reset, please ignore this email. This link will expire in 24 hours.

-

Thank you,
The Steamy Sips Team

-
- +
+
+ Steamy Sips Logo +
+
+

Reset Your Password

+

Hello,

+

We received a request to reset the password for the account associated with . Click the button below to reset your password:

+

Reset My Password

+

If you did not request a password reset, please ignore this email. This link will expire in 24 hours.

+

Thank you,
The Steamy Sips Team

+
+ +