fix(email): use client/org name as From display, not Ladill product
Deploy Ladill Events / deploy (push) Successful in 45s
Deploy Ladill Events / deploy (push) Successful in 45s
Customer-facing outbound mail should appear from the business (organizer, clinic, company, location), not the Ladill product brand.
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Services\Events;
|
||||
use App\Services\Billing\PlatformEmailClient;
|
||||
use App\Services\Messaging\CustomerEmailClient;
|
||||
use App\Services\Messaging\MessagingCredentialsService;
|
||||
use App\Support\AccountBranding;
|
||||
|
||||
/**
|
||||
* Attendee/speaker email: prefer platform suite messaging (zero-config mailbox),
|
||||
@@ -48,18 +49,20 @@ class EventMailer
|
||||
?string $text = null,
|
||||
?string $replyToEmail = null,
|
||||
?string $replyToName = null,
|
||||
?string $fromName = null,
|
||||
): bool {
|
||||
$this->lastError = null;
|
||||
$displayName = $this->resolveFromName($ownerPublicId, $fromName, $replyToName);
|
||||
|
||||
if ($this->platformEmail->isConfigured()) {
|
||||
$sent = $this->platformEmail->send($ownerPublicId, $to, $subject, $html, $text);
|
||||
$sent = $this->platformEmail->send($ownerPublicId, $to, $subject, $html, $text, $displayName);
|
||||
if ($sent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Suite unavailable (mailbox, allowance) — try Bird power-user path next.
|
||||
$suiteError = $this->platformEmail->lastError();
|
||||
if ($this->tryCustomerBird($ownerPublicId, $to, $subject, $html, $text)) {
|
||||
if ($this->tryCustomerBird($ownerPublicId, $to, $subject, $html, $text, $displayName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -68,7 +71,22 @@ class EventMailer
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->tryCustomerBird($ownerPublicId, $to, $subject, $html, $text);
|
||||
return $this->tryCustomerBird($ownerPublicId, $to, $subject, $html, $text, $displayName);
|
||||
}
|
||||
|
||||
private function resolveFromName(string $ownerPublicId, ?string $fromName, ?string $replyToName): ?string
|
||||
{
|
||||
foreach ([$fromName, $replyToName] as $candidate) {
|
||||
$name = trim((string) $candidate);
|
||||
if ($name !== '') {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
||||
$settings = AccountBranding::forOwnerRef($ownerPublicId);
|
||||
$company = trim(AccountBranding::companyName($settings));
|
||||
|
||||
return $company !== '' && strcasecmp($company, 'Company') !== 0 ? $company : null;
|
||||
}
|
||||
|
||||
private function tryCustomerBird(
|
||||
@@ -77,6 +95,7 @@ class EventMailer
|
||||
string $subject,
|
||||
string $html,
|
||||
?string $text,
|
||||
?string $fromName = null,
|
||||
): bool {
|
||||
$credential = $this->credentials->forOwner($ownerPublicId);
|
||||
if (! $credential->hasValidBird()) {
|
||||
@@ -95,7 +114,7 @@ class EventMailer
|
||||
$sent = $this->customerEmail->send(
|
||||
$apiKey,
|
||||
(string) $credential->bird_from_email,
|
||||
$credential->bird_from_name,
|
||||
$credential->bird_from_name ?: $fromName,
|
||||
$to,
|
||||
$subject,
|
||||
$html,
|
||||
|
||||
Reference in New Issue
Block a user