-
app/Http/Controllers/PageController.php
Open in GitHubuse App\Mail\ContactFormSubmitted; use App\Rules\Recaptcha; use Illuminate\Http\Request; use Illuminate\Support\Facades\Mail; use Inertia\Inertia; class PageController extends Controller { // public function contactFormSubmit(Request $request) { $this->validate($request, [ 'name' => 'required|string', 'email' => 'required|email', 'start' => 'required', 'type' => 'required', 'remote' => 'required', 'description' => 'required', 'captcha_token' => ['required', new Recaptcha] ]); Mail::to(config('mail.to.address'))->send(new ContactFormSubmitted($request)); return response()->json(null, 200); } // }
-
app/Mail/ContactFormSubmitted.php
Open in GitHubuse Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; class ContactFormSubmitted extends Mailable { use Queueable, SerializesModels; public $message; public function __construct($message) { $this->message = $message; } public function build() { return $this->markdown('emails.contact'); } }
-
resources/views/emails/contact.blade.php
Open in GitHub@component('mail::message') # New Message from Contact Form @component('mail::table') | Name | email | Start | Type | Remote | Start | | ------------- |:-------------:| --------:| | ------------- |:-------------:| --------:| | {{$message->name}} | {{$message->email}} | {{$message->start}} | {{$message->type}} | {{$message->remote}} | {{$message->start}}| @endcomponent Description: {{$message->description}} Thanks,<br> {{ config('app.name') }} @endcomponent