<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
/**
* Sent to the store's contact address whenever a visitor submits the
* Contact Us form. Previously built via Mail::raw() with an inline
* closure — switched to a real Mailable so it can actually be asserted
* on with Mail::fake()->assertSent() in tests (Mail::raw() sends never
* go through a Mailable instance at all, so MailFake has no way to see
* them — Mail::assertSent()/assertNothingSent() against a raw send are
* silently no-ops either way).
*/
class ContactFormMail extends Mailable
{
use Queueable, SerializesModels;
public function __construct(
public string $name,
public string $fromEmail,
public ?string $contactSubject,
public string $messageBody,
) {}
public function envelope(): Envelope
{
return new Envelope(
subject: 'Contact form: ' . ($this->contactSubject !== null && $this->contactSubject !== ''
? $this->contactSubject
: 'New message from ' . $this->name),
replyTo: [$this->fromEmail => $this->name],
);
}
public function content(): Content
{
return new Content(view: 'emails.contact.submitted');
}
}