diff --git a/app/Mail/ContactMessageMail.php b/app/Mail/ContactMessageMail.php index 842ccad..d111ebe 100644 --- a/app/Mail/ContactMessageMail.php +++ b/app/Mail/ContactMessageMail.php @@ -4,6 +4,7 @@ namespace App\Mail; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; +use Illuminate\Mail\Mailables\Address; use Illuminate\Mail\Mailables\Content; use Illuminate\Mail\Mailables\Envelope; use Illuminate\Queue\SerializesModels; @@ -23,7 +24,13 @@ class ContactMessageMail extends Mailable public function envelope(): Envelope { + $display = trim((string) ($this->fromName ?: $this->companyName)); + $fromAddress = (string) config('mail.from.address'); + return new Envelope( + from: $display !== '' && $fromAddress !== '' + ? new Address($fromAddress, $display) + : null, subject: $this->subjectLine, replyTo: $this->replyToAddress ? [$this->replyToAddress] : [], ); diff --git a/app/Services/Comms/EmailService.php b/app/Services/Comms/EmailService.php index fc89c94..0202961 100644 --- a/app/Services/Comms/EmailService.php +++ b/app/Services/Comms/EmailService.php @@ -27,9 +27,11 @@ class EmailService $logoUrl = OrganizationBranding::emailLogoUrl($organization); $companyName = $organization->name; } + // Client-facing From display: org/company name, never the Ladill product brand. + $displayName = trim((string) ($fromName ?: $companyName)) ?: null; try { - Mail::to($to)->send(new ContactMessageMail($subject, $body, $fromName, $replyTo, $logoUrl, $companyName)); + Mail::to($to)->send(new ContactMessageMail($subject, $body, $displayName, $replyTo, $logoUrl, $companyName)); return true; } catch (\Throwable $e) { diff --git a/app/Services/Qms/QueueNotificationService.php b/app/Services/Qms/QueueNotificationService.php index a8c37d8..9a9118a 100644 --- a/app/Services/Qms/QueueNotificationService.php +++ b/app/Services/Qms/QueueNotificationService.php @@ -77,7 +77,8 @@ class QueueNotificationService $this->sms->send($phone, $message); } if ($email) { - $this->email->send($email, 'Ladill Queue update', $message, null, null, $organization); + $orgName = trim((string) ($organization?->name ?? '')) ?: 'Queue'; + $this->email->send($email, $orgName.' — queue update', $message, $orgName, null, $organization); } }