mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-18 02:34:08 +00:00
Fix invitation email: load relationships and handle mail failures gracefully
The CompanyInvitationMail accesses company, role, and invitedBy relationships which weren't loaded before sending. Also wrap mail send in try-catch so the invitation is still created even if the mailer is misconfigured (logs a warning instead of crashing).
This commit is contained in:
@@ -52,7 +52,13 @@ class InvitationService
|
||||
'expires_at' => Carbon::now()->addDays(7),
|
||||
]);
|
||||
|
||||
Mail::to($email)->send(new CompanyInvitationMail($invitation));
|
||||
$invitation->load(['company', 'role', 'invitedBy']);
|
||||
|
||||
try {
|
||||
Mail::to($email)->send(new CompanyInvitationMail($invitation));
|
||||
} catch (\Exception $e) {
|
||||
\Log::warning('Failed to send invitation email to '.$email.': '.$e->getMessage());
|
||||
}
|
||||
|
||||
return $invitation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user