ip(); if (RateLimiter::tooManyAttempts($key, self::SEND_LIMIT)) { return back()->withInput()->with('contact_error', __('storefront.contact.too_many')); } RateLimiter::hit($key, self::SEND_DECAY_SECONDS); $data = $request->validated(); $to = config('services.contact.email'); try { if (blank($to)) { throw new \RuntimeException('CONTACT_EMAIL is not set.'); } Mail::to($to)->send(new ContactMessageMail( $data['name'], $data['email'], $data['message'], $locale, )); } catch (Throwable $e) { Log::error('Contact form: store email failed', ['exception' => $e]); return back()->withInput()->with('contact_error', __('storefront.contact.send_failed')); } // The store already has the message, so a failed confirmation is only logged. try { Mail::to($data['email'])->locale($locale)->send(new ContactConfirmationMail); } catch (Throwable $e) { Log::warning('Contact form: confirmation email failed', ['exception' => $e]); } return redirect()->route('contact')->with('status', __('storefront.contact.sent')); } }