Build Laravel 5.7 Email Authentication with Mailgun and Digital Ocean
Build session authentication with email verification into a default Laravel 5.7 app
The newly released Laravel version 5.7 adds a new capability to verify user’s emails. If you’ve ever ran php artisan make:auth
within a Laravel app you’ll know the feeling of pleasure and excitement when you see all of your register and login pages, complete with password hashing and a users table already built out. This excitement will soon subside after deploying to production only to find that anyone can register with garbage@notrealemail.com
or whatever they feel like typing in. This thin session authentication layer doesn’t help much in a live application. The introduction of Laravel 5.7’s MustVerifyEmail
interface adds to the authentication scaffold so that in order for users to login they must use a real, valid email address.
Create a new Laravel application
The first step is to create a new application with some setup:
$ laravel new email-verification-example
$ php artisan make:auth
Authentication scaffolding generated successfully.
$ touch database/database.sqlite