PHPackages                             kadirgulec/newsletter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kadirgulec/newsletter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kadirgulec/newsletter
=====================

A robust newsletter package for Laravel

v1.1.0(4mo ago)116MITPHP

Since Dec 23Pushed 1mo agoCompare

[ Source](https://github.com/kadirgulec/laravel-newsletter)[ Packagist](https://packagist.org/packages/kadirgulec/newsletter)[ RSS](/packages/kadirgulec-newsletter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (6)Used By (0)

Laravel Newsletter Package
==========================

[](#laravel-newsletter-package)

A lightweight, database-driven newsletter system for Laravel. It handles subscriptions, unsubscriptions via secure signed URLs, and sends RFC-compliant emails to ensure high deliverability (Gmail/Outlook friendly).

Features
--------

[](#features)

- 📦 **Database Storage:** Saves subscribers to a local `newsletter_subscribers` table.
- 🔒 **Signed Unsubscribe Links:** Prevents users from unsubscribing others by protecting the route with a cryptographic signature.
- 📧 **RFC Compliance:** Automatically adds `List-Unsubscribe` headers to email responses.
- 🎨 **Ready-to-use Views:** Includes a standard email layout and unsubscribe success page.
- ⚡ **Laravel 10, 11 &amp; 12 Support.**

---

Installation
------------

[](#installation)

### Installing via Composer

[](#installing-via-composer)

```
    composer require kadirgulec/newsletter
```

### Post-Installation

[](#post-installation)

After installing, run the migrations to create the subscribers table:

```
    php artisan migrate
```

---

Usage
-----

[](#usage)

### 1. The Subscription Form

[](#1-the-subscription-form)

You can place this HTML form anywhere in your application (footer, sidebar, popup, etc.).

```

    @if(session('success'))
        {{ session('success') }}
    @endif

    @error('email')
        {{ $message }}
    @enderror

        @csrf

        Subscribe

```

### 2. Sending a Newsletter

[](#2-sending-a-newsletter)

You can send a newsletter from any Controller, Artisan Command, or Job.

```
    use Illuminate\Support\Facades\Mail;
    use KadirGulec\Newsletter\Models\Subscriber;
    use KadirGulec\Newsletter\Mail\NewsletterMail;

    // 1. Fetch only active subscribers
    $subscribers = Subscriber::active()->get();

    // 2. Iterate and send
    foreach ($subscribers as $subscriber) {
        Mail::to($subscriber->email)->send(
            new NewsletterMail(
                $subscriber,                                // 1. Subscriber Model
                "Weekly Digest: New Updates",               // 2. Email Subject
                "Hello!Here is the news..." // 3. Email Content (HTML)
            )
        );
    }

```

> **Tip:** For large lists, it is highly recommended to queue these emails using Laravel Jobs to prevent your page from timing out.

### 3. Unsubscribing

[](#3-unsubscribing)

This process is automated.

1. Every email sent via `NewsletterMail` includes a **Footer Link** and a **Hidden Header** (`List-Unsubscribe`).
2. The link points to a **Signed Route** (`/newsletter/unsubscribe/{id}?signature=...`).
3. If the user clicks it, their status in the database is updated to `is_subscribed = false` and they are shown a success message.

---

Database Structure
------------------

[](#database-structure)

The package creates a table named `newsletter_subscribers`.

ColumnTypeDescription`id`BigIntPrimary Key`email`StringUnique email address`is_subscribed`Boolean`true` = Active, `false` = Unsubscribed`unsubscribed_at`TimestampNullable. Date when user unsubscribed`created_at`TimestampSubscription dateThe package also creates a table named `newsletter_campaigns`.

ColumnTypeDescription`id`BigIntPrimary Key`subject`StringThe email subject`content`LongTextThe HTML content of the email`status`String`draft` or `sent``sent_at`TimestampNullable. Date when the campaign was sent---

Customization
-------------

[](#customization)

### Publishing Views

[](#publishing-views)

You can publish the email layout and the "Unsubscribe Success" page to your main `resources/views` folder to customize them.

```
    php artisan vendor:publish --tag=newsletter-views
```

This will generate:

1. `resources/views/vendor/newsletter/email/standard.blade.php` (The Email Layout)
2. `resources/views/vendor/newsletter/unsubscribe-success.blade.php` (The "You have unsubscribed" page)

### Extending the Model

[](#extending-the-model)

If you need to add relationships (e.g., linking a subscriber to a `User`), you can extend the model or use the provided one:

```
    use KadirGulec\Newsletter\Models\Subscriber;

    // Check if a specific email is subscribed
    $isSubscribed = Subscriber::where('email', 'john@doe.com')->first()?->is_subscribed;
```

---

Troubleshooting
---------------

[](#troubleshooting)

**Error: Route \[newsletter.subscribe\] not defined.**

- Ensure the service provider is loaded. Run `php artisan route:list | grep newsletter` to check if routes are registered.
- Try running `php artisan optimize:clear`.

**Error: 403 Invalid Signature on Unsubscribe.**

- This happens if the URL is modified. Ensure your `APP_URL` in `.env` is set correctly (e.g., `http://localhost:8000` or `https://yourdomain.com`). Signed routes use the `APP_URL` to generate the signature.

---

Testing
-------

[](#testing)

The package includes a comprehensive test suite using PHPUnit and Orchestra Testbench.

### Running Tests

[](#running-tests)

1. Install development dependencies:

```
    composer install
```

2. Run the tests:

```
    vendor/bin/phpunit
```

The tests cover:

- **Subscriber Model:** Active/Inactive scoping.
- **Newsletter Controller:** Subscription process and welcome email delivery.
- **Unsubscription:** Secure signed URL validation and status updates.
- **Campaigns:** Correct batch queueing to active subscribers only.

---

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance83

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

140d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2fa2b1b34e7f6dcd2d1a436a69cee3f5cd5c469fcf063b3dca08617ee1cdd991?d=identicon)[kadirgulec](/maintainers/kadirgulec)

---

Top Contributors

[![kadirgulec](https://avatars.githubusercontent.com/u/122262662?v=4)](https://github.com/kadirgulec "kadirgulec (13 commits)")

### Embed Badge

![Health badge](/badges/kadirgulec-newsletter/health.svg)

```
[![Health](https://phpackages.com/badges/kadirgulec-newsletter/health.svg)](https://phpackages.com/packages/kadirgulec-newsletter)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
