Mail facade is in the global namespace. The call should be:
\Mail::to('[email protected]')->send(new ContactUS($data));
or add use Mail;
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Ok so I'm trying to send a mail with this controller but when I hit send on the form to call the controller I get a message saying the ContactUs class is not found, even though ContactUs.php is indeed in App\Mail
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Mail\ContactUs;
use Illuminate\Support\Facades\Mail;
class ContactUSController extends Controller
{
public function contactUSPost(Request $request)
{
$data = request()->validate([
'name' => 'required',
'email' => 'required|email',
'number' => 'required',
'message' => 'required'
]);
Mail::to('[email protected]')->send(new ContactUS($data));
return back()->with('complete', 'Thanks for contacting us!');
}
}
Have I made an obvious mistake here?
class ContactMail extends Mailable
{
Your class is defined as ContactMail, not ContactUs. Change it to ContactUs.
Please or to participate in this conversation.