Laravel 5.1 How to send email verification email after registration?

Ali Erfani picture Ali Erfani · Aug 15, 2015 · Viewed 9.4k times · Source

I need users to verify their email address after registration. I have confirmation_code and confirmed fields in users table. How can I send an email after a user registration?

Answer

cre8 picture cre8 · Aug 15, 2015

You need a normal blade template being the body

Mail::send('emails.reminder', ['user' => $user], function ($m) use ($user) {
    $m->to($user->email, $user->name)->subject('Your Reminder!');
});

In just place a the confirmation_code in the email and define a route, e.g. mypage.com/emailverification/1389734jhikdfsjkb1234908adkb

When the user vists the link you check the database for this entry and set the status of the registration to completed.

For more information check http://laravel.com/docs/5.1/mail#sending-mail

For a detailed tutorial check: http://bensmith.io/email-verification-with-laravel