Laravel Create Newsletter Example Tutorial




Laravel Create Newsletter Example Tutorial

Hi Guys,

In this tutorial,I will learn you how to use newsletter in can easy and simply use newsletter in laravel.

Step 1 : Install Laravel App

In this step, You can install laravel fresh app. So open terminal and put the bellow command.

composer create-project --prefer-dist laravel/laravel blog

Step 2 : Setup Database Configuration

After successfully install laravel app thenafter configure databse setup. We will open ".env" file and change the database name, username and password in the env file.







Step 3: Install Newsletter Package

In this step,you can install newsletters in command terminal.bellow this command.

composer require spatie/laravel-newsletter

The package will automatically register itself.

To publish the config file to config/newsletter.php run:

php artisan vendor:publish --provider="Spatie\Newsletter\NewsletterServiceProvider"

Step 4: Sign Up in MailChimp Get MailChimp API Key And List Id

Now, you sign up in MailChimp from If you have already account then sign in. After successfully sign up or sign we can get api key and list id from mailchimp

Step 5: SignSet MailChimp API Key And List Id in .env file

Next, we need to update the Mailchimp API key and list id in.env file:



Step 6: Create Route

now, we need to add for NewsletterController in laravel application. so open your "routes/web.php" file and add following route.




Step 7: Create Controler

Here this step now we should create new controller as NewsletterController. So run bellow command and create new controller.

php artisan make:controller NewsletterController

successfully run above command then,you can create method for get courses and fetch record students table. So Let's copy bellow and put in the controller file.



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Newsletter;

class NewsletterController extends Controller


public function index()


return view('newsletter');


public function store(Request $request)


if ( ! Newsletter::isSubscribed($request->email) )



return redirect('newsletter')->with('success', 'Thanks For Subscribe');


return redirect('newsletter')->with('failure', 'Sorry! You have already subscribed ');



Step 8: Create Blade File

In this step,you can create to layout in this blade file.


<!DOCTYPE html>



<meta charset="utf-8">

<title>Laravel Newsletter Tutorial With Example</title>

<link rel="stylesheet" href="{{asset('css/app.css')}}">

<link rel="stylesheet" href="">



<div class="container">

@if (\Session::has('success'))

<div class="alert alert-success">

<p>{{ \Session::get('success') }}</p>

</div><br />


@if (\Session::has('failure'))

<div class="alert alert-danger">

<p>{{ \Session::get('failure') }}</p>

</div><br />


<h2 class="mb-2 mt-2">Laravel Newsletter Tutorial With Example</h2>

<form method="post" action="{{url('newsletter/store')}}">



<div class="row">

<div class="col-md-8"></div>

<div class="form-group col-md-2">

<label for="Email">Email:</label>

<input type="text" class="form-control" name="email">



<div class="row">

<div class="col-md-4"></div>

<div class="form-group col-md-4">

<button type="submit" class="btn btn-success">Submit</button>







Now we are ready to run our example so run bellow command for quick run:

php artisan serve

Now you can open bellow URL on your browser:


It will help you....

#Laravel 7


#Laravel 6