This answer assumes you've already setup Laravel's Authentication and Email Verification.
When a user registers on the application, the controller by default is using the Illuminate\Foundation\Auth\RegistersUser
trait. Notice the additional functionality that takes place in the register()
method there, and also notice that a \Illuminate\Auth\Events\Registered
event is generated which in turns triggers the listener SendEmailVerificationNotification
(where you are currently getting your code from.)
For your custom class, you could potentially reuse the Illuminate\Foundation\Auth\RegistersUser
trait on it, but that could feel strange as your class is probably not a controller and the trait involves extra controller-specific logic.
Instead, you could try ripping some code from Illuminate\Foundation\Auth\RegistersUser::register()
and use it within your new class.
So, something similar to:
// If you do not yet have a new user object.
$user = \App\User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => \Illuminate\Support\Facades\Hash::make($data['password']),
]);
// Fire the event now with the user you want to receive an email.
event(new \Illuminate\Auth\Events\Registered($user));
More information: