Support the ongoing development of Laravel.io →
Validation Mail
Last updated 1 year ago.
0

I know this was posted 9 months ago, but I'm needing to do the same thing. I may have to go to Google for this one...

0

You can create email code for when you trying to add new user record by backend. Also you can try this code.

public function register(Request $request) { // Laravel validation $validator = $this->validator($request->all()); if ($validator->fails()) { $this->throwValidationException($request, $validator); } // Using database transactions is useful here because stuff happening is actually a transaction // I don't know what I said in the last line! Weird! DB::beginTransaction(); try { $user = $this->create($request->all()); // After creating the user send an email with the random token generated in the create method above $email = new EmailVerification(new User(['email_token' => $user->email_token, 'name' => $user->name])); Mail::to($user->email)->send($email); DB::commit(); \Session::flash('success','Email sent.. Please verify your account before login. '); return back(); } catch(Exception $e) { DB::rollback(); return back(); } }

By:Xtreem Solution

Highly Skilled Laravel Developer

Dedicated PHP Developer

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.