Brand Frontdesk Laravel mail for hosts and report recipients.
Deploy Ladill Frontdesk / deploy (push) Has been cancelled
Deploy Ladill Frontdesk / deploy (push) Has been cancelled
Pass organization logo/name through ContactMessageMail for daily reports and campaigns, and drop the Ladill product footer. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace App\Services\Comms;
|
||||
|
||||
use App\Mail\ContactMessageMail;
|
||||
use App\Models\Organization;
|
||||
use App\Support\OrganizationBranding;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
@@ -13,18 +15,31 @@ use Illuminate\Support\Facades\Mail;
|
||||
*/
|
||||
class EmailService
|
||||
{
|
||||
public function send(string $to, string $subject, string $body, ?string $fromName = null, ?string $replyTo = null): bool
|
||||
{
|
||||
public function send(
|
||||
string $to,
|
||||
string $subject,
|
||||
string $body,
|
||||
?string $fromName = null,
|
||||
?string $replyTo = null,
|
||||
?Organization $organization = null,
|
||||
): bool {
|
||||
if (! filter_var($to, FILTER_VALIDATE_EMAIL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$logoUrl = null;
|
||||
$companyName = null;
|
||||
if ($organization) {
|
||||
$logoUrl = OrganizationBranding::emailLogoUrl($organization);
|
||||
$companyName = $organization->name;
|
||||
}
|
||||
|
||||
try {
|
||||
Mail::to($to)->send(new ContactMessageMail($subject, $body, $fromName, $replyTo));
|
||||
Mail::to($to)->send(new ContactMessageMail($subject, $body, $fromName, $replyTo, $logoUrl, $companyName));
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('CRM email send failed', ['to' => $to, 'error' => $e->getMessage()]);
|
||||
Log::warning('Frontdesk email send failed', ['to' => $to, 'error' => $e->getMessage()]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user