# Notification Letter Wireframe (SMTP + phpmail())

## SMTP/Laravel Mailer Skeleton

Use this for system notifications such as:
- earnings credit pending/processing/credited
- invoice payment debit
- operations completion/new entry

```env
MAIL_MAILER=smtp
MAIL_HOST=smtp.yourprovider.com
MAIL_PORT=587
MAIL_USERNAME=notifications@yourdomain.com
MAIL_PASSWORD=app-password-or-token
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=notifications@yourdomain.com
MAIL_FROM_NAME="Commodity Trading Operations"
```

```php
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class FinancialLifecycleLetter extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct(
        public string $subjectLine,
        public string $headline,
        public string $body,
        public array $context = []
    ) {
    }

    public function build(): self
    {
        return $this->subject($this->subjectLine)
            ->view('mail.financial-lifecycle-letter');
    }
}
```

```blade
{{-- resources/views/mail/financial-lifecycle-letter.blade.php --}}
<!doctype html>
<html>
<body style="font-family: Arial, sans-serif; color: #111;">
    <h2>{{ $headline }}</h2>
    <p>{{ $body }}</p>
    <hr>
    <p><strong>Reference:</strong> {{ $context['reference'] ?? 'N/A' }}</p>
    <p><strong>Amount:</strong> {{ $context['amount'] ?? 'N/A' }}</p>
    <p><strong>Status:</strong> {{ $context['status'] ?? 'N/A' }}</p>
    <p><strong>Timestamp:</strong> {{ now()->toDateTimeString() }}</p>
    <p style="margin-top: 16px; color: #555;">Commodity Trading Operations & Treasury Platform</p>
</body>
</html>
```

## phpmail() Wireframe

Use this when SMTP library integration is not available and you need a lightweight fallback.

```php
<?php

function sendLifecycleLetter(
    string $toEmail,
    string $subject,
    string $headline,
    string $body,
    array $context = []
): bool {
    $headers = [];
    $headers[] = 'MIME-Version: 1.0';
    $headers[] = 'Content-type: text/html; charset=UTF-8';
    $headers[] = 'From: Commodity Trading Operations <notifications@yourdomain.com>';

    $html = '
        <html><body style="font-family: Arial, sans-serif; color:#111;">
            <h2>'.htmlspecialchars($headline).'</h2>
            <p>'.htmlspecialchars($body).'</p>
            <hr />
            <p><strong>Reference:</strong> '.htmlspecialchars((string) ($context['reference'] ?? 'N/A')).'</p>
            <p><strong>Amount:</strong> '.htmlspecialchars((string) ($context['amount'] ?? 'N/A')).'</p>
            <p><strong>Status:</strong> '.htmlspecialchars((string) ($context['status'] ?? 'N/A')).'</p>
            <p><strong>Timestamp:</strong> '.date('Y-m-d H:i:s').'</p>
        </body></html>
    ';

    return mail($toEmail, $subject, $html, implode("\r\n", $headers));
}
```

## Suggested Notification Subjects

- `Earnings credit pending`
- `Earnings credit processing`
- `Earnings credited`
- `Invoice payment debited`
- `Operations completed and archived`
