initial
Some checks failed
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 2m50s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 2m59s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 3m11s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 3m33s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Failing after 3m18s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Failing after 1m14s

This commit is contained in:
2026-01-15 14:33:51 -05:00
parent a1d7512ebc
commit b2b85b5261
6 changed files with 147 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace Siteworxpro\App\Mailer\Drivers;
use Siteworxpro\App\Mailer\Message;
interface DriverInterface
{
public function send(Message $message): bool;
}

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace Siteworxpro\App\Mailer\Drivers;
use Siteworxpro\App\Mailer\Message;
use Siteworxpro\App\Services\Facades\Logger;
class Log implements DriverInterface
{
public function send(Message $message): bool
{
$logMessage = `
===============================================
To: {$message->getTo()}
Subject: {$message->getSubject()}
Body:
{$this->formatBodyForLog($message->getBody())}
===============================================
`;
Logger::info($logMessage);
return true;
}
private function formatBodyForLog(string $body): string
{
$body = str_replace('<br>', "\n", $body);
$body = str_replace('<br/>', "\n", $body);
$body = strip_tags($body);
return wordwrap($body, 80);
}
}

33
src/Mailer/Message.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Siteworxpro\App\Mailer;
readonly class Message
{
public function __construct(
private string $to,
private string $subject,
private string $body
) {
if ($to != filter_var($to, FILTER_VALIDATE_EMAIL)) {
throw new \InvalidArgumentException('Invalid email address provided.');
}
}
public function getTo(): string
{
return $this->to;
}
public function getSubject(): string
{
return $this->subject;
}
public function getBody(): string
{
return $this->body;
}
}

25
src/Mailer/Sendmail.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace Siteworxpro\App\Mailer;
use Siteworxpro\App\Services\Facades\Config;
class Sendmail
{
private Drivers\DriverInterface $driver;
public function __construct()
{
$this->driver = match (Config::get('mailer.driver')) {
'log' => new Drivers\Log(),
default => throw new \InvalidArgumentException('Invalid mailer driver specified.'),
};
}
public function send(Message $message): bool
{
return $this->driver->send($message);
}
}

View File

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ subject }}</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f9f9f9;
margin: 0;
padding: 20px;
}
.container {
background-color: #ffffff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body>
{{ content|raw }}
</body>
</html>

View File

@@ -0,0 +1,17 @@
{% extends _base.twig %}
{% block subject %}
Password Reset Request
{% endblock %}
{% block body %}
<p>Dear {{ user.firstName }},</p>
<p>We received a request to reset your password. Click the link below to set a new password:</p>
<p><a href="{{ resetLink }}">Reset Your Password</a></p>
<p>If you did not request a password reset, please ignore this email.</p>
<p>Best regards,<br>{{ client.name }}</p>
{% endblock %}