How to Create Newsletter in Laravel 10

Websolutionstuff | Nov-29-2023 | Categories : Laravel

Hey there! In this article, I'm thrilled to guide you through the exciting world of creating newsletters in Laravel 10. As we navigate this together, you'll discover how to effortlessly design, compose, and send newsletters that captivate your audience.

Let's dive into the simplicity and effectiveness of crafting newsletters using Laravel 10, making communication a breeze!

Also, you can use in newsletter in Laravel 8, Laravel 9, and Laravel 10.


Here's a step-by-step guide on how to create a newsletter in Laravel 10:

Step 1: Set Up a New Laravel 10 Project

If you don't have a Laravel 10 project yet, create one using the following command in your terminal:

composer create-project laravel/laravel newsletter-laravel-10


Step 2: Configure Database

Open the .env file in your project and set up your database configuration.



Step 3: Install Newsletter Package

Run the following command to install the Laravel Newsletter package using Composer:

composer require spatie/laravel-newsletter

Note: This is for older laravel version

After the package is installed, open the config/app.php file.

Add the following service provider to the providers array:

'providers' => [
    // Other providers...


'aliases' => [
    // Other aliases...

    'Newsletter' => Spatie\Newsletter\NewsletterFacade::class,

Run the following command to publish the configuration file:

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


Step 4: Sign Up in MailChimp, Get the MailChimp API Key and List the ID
  1. Sign Up on MailChimp:

    • If you don't have a MailChimp account, visit the MailChimp website and sign up for a free account.
  2. Log in to MailChimp:

    • Log in to your MailChimp account using your credentials.
  3. Navigate to Dashboard:

    • After logging in, go to the MailChimp dashboard.
  4. Access API Keys:

    • Click on your account name in the top right corner and select "Account."
    • Under the "Extras" dropdown, choose "API keys."
  5. Generate an API Key:

    • If you don't have an API key, generate a new one. Copy the generated key; you will need it to configure the Laravel Newsletter package.


Step 5: Set Environment Variables:

In your .env file, set the following environment variables




Step 6: Create a Route for Newsletter Preview

In your web.php routes file, add a route to preview your newsletter:



Step 7: Create a Controller

Now, create a NewsletterController using the following command:

php artisan make:controller NewsletterController



namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Newsletter;

class NewsletterController extends Controller
    public function index()
        return view('news-letter');

    public function store(Request $request)
        if (!Newsletter::isSubscribed($request->email) ) 
            return redirect('newsletter')->with('success', 'Thanks For Subscribe Our Website');
        return redirect('newsletter')->with('failure', 'Sorry! You have already subscribed');


Step 8: Create Blade File

Navigate to the resources/views directory. create a new Blade file. For example, let's name it news-letter.blade.php

<!DOCTYPE html>
		<meta charset="utf-8">
		<title>How to Create Newsletter in Laravel 10 - Websolutionstuff</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">How to Create Newsletter in Laravel 10 - Websolutionstuff</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>


Step 9: Test the Newsletter Preview

Run your Laravel development server:

php artisan serve


You might also like:

Recommended Post
Featured Post
How To Add Ckeditor In Laravel
How To Add Ckeditor In Laravel

In this article, I will explain you how to add ckeditor in laravel, CKEditor is a WYSIWYG rich text edito...

Read More


PHP Access Modifiers Example
PHP Access Modifiers Example

In this example we will see PHP access modifiers example. In PHP default access modifier is public. PHP provide differen...

Read More


Carbon Add Hours To Date In Laravel 9
Carbon Add Hours To Date In La...

In this article, we will see carbon add hours to date in laravel 9. Carbon provides addHour and addHours() function...

Read More


How to Set Auto Database BackUp using Cron Scheduler In Laravel
How to Set Auto Database BackU...

In this article, we will see how to set auto database backup using the cron scheduler in laravel. here we will set ...

Read More