PHPackages                             lywebdev/laravel-mailblocks - 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. [Templating &amp; Views](/categories/templating)
4. /
5. lywebdev/laravel-mailblocks

ActiveLibrary[Templating &amp; Views](/categories/templating)

lywebdev/laravel-mailblocks
===========================

Composable email templates builder for Laravel.

00PHP

Since Nov 14Pushed 6mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Mailblocks
==================

[](#laravel-mailblocks)

MailBlocks is a component-based email builder for Laravel 10-12. Describe your transactional or marketing messages as PHP objects (headings, grids, rows, boxes, tables, etc.) and let the package render bulletproof markup automatically. Repository: .

Documentation languages
-----------------------

[](#documentation-languages)

- [English](README.md)
- [Русский](docs/README.ru.md)
- [Українська](docs/README.uk.md)
- [Nederlands](docs/README.nl.md)

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

[](#installation)

```
composer require lywebdev/laravel-mailblocks
```

Quick start with `MailTemplate`
-------------------------------

[](#quick-start-with-mailtemplate)

```
use MailBlocks\MailTemplate;
use MailBlocks\Components\{Button, Divider, Heading, Paragraph};

class OrderPaidMail extends MailTemplate
{
    public function __construct(
        private string $orderNumber,
        private string $orderUrl,
    ) {}

    public function build(): array
    {
        return [
            Heading::make('Order #' . $this->orderNumber)->center(),
            Paragraph::make('Your payment was received.'),
            Button::make('View order', $this->orderUrl),
            Divider::make()->margin('16px 0'),
            Paragraph::make('Thank you for staying with us!')->center(),
        ];
    }
}
```

Use it inside any `Mailable`:

```
public function content(): Content
{
    return (new OrderPaidMail($this->orderNumber, $this->orderUrl))->toContent();
}
```

Using `MailComposer`
--------------------

[](#using-mailcomposer)

```
use MailBlocks\MailComposer;
use MailBlocks\Components\{
    Box, Button, Divider, Grid\Column, Grid\Grid,
    Heading, Image, Paragraph, Row, Table
};

$html = MailComposer::make([
    Heading::make('Product Digest')->center(),
    Paragraph::make('Mix hero copy, CTA buttons, cards and tables in just a few calls.'),

    Row::make([
        Button::make('Start campaign', 'https://example.com/campaigns'),
        Button::make('Update profile', 'https://example.com/profile')->right(),
    ])->gap(20)->alignCenter(),

    Grid::make([
        Column::make(9)
            ->add(Heading::make('Campaign status')->h2()->left())
            ->add(Paragraph::make('Track opens, clicks and delivery in real time.'))
            ->add(Button::make('View report', 'https://example.com/report')->right()),
        Column::make(3)
            ->verticalCenter()
            ->add(Image::make(
                'https://via.placeholder.com/320x200.png?text=MailBlocks',
                'Dashboard preview',
                320
            )->rounded(24)->center()),
    ], gap: 20),

    Divider::make()->margin('32px 0'),

    Table::make(
        ['Metric', 'Value', 'Delta vs last week'],
        [
            ['CTR', '34%', '+3.2%'],
            ['Conversions', '1,204', '+18%'],
            ['Average order', '$105', '-2%'],
        ]
    )->marginTop('24px'),
])->renderHtml();
```

Components overview
-------------------

[](#components-overview)

- **Text**: `Heading`, `Paragraph`, `Section`, `Divider`.
- **CTA &amp; media**: `Button`, `Image`.
- **Layouts**: `Grid` + `Column` (12-column system with `gap` and vertical alignment helpers), `Row` (inline blocks with `justify*/align*/gap()`), `Box` (fixed-width container with `containerWidth()` + `verticalGap()`).
- **Data**: `Table` ships with a modern dashboard look (rounded corners, zebra rows, shadow).
- Every component supports shared helpers: `padding()`, `margin*()`, `width()/height()`, `containerWidth()`, `outline()`, `align()`, etc.
- `MailTemplate` and `MailComposer` only accept explicit component objects, so you always see the full layout in PHP.

### Dashboard-styled table

[](#dashboard-styled-table)

```
use MailBlocks\Components\Table;

Table::make(
    ['Metric', 'Value', 'Delta vs last week'],
    [
        ['CTR', '34%', '+3.2%'],
        ['Conversions', '1,204', '+18%'],
        ['Average order', '$105', '-2%'],
    ]
)->marginTop('24px')->outline('#e2e8f0');
```

Customizing the layout, header, and footer
------------------------------------------

[](#customizing-the-layout-header-and-footer)

### Config-driven tweaks

[](#config-driven-tweaks)

1. Publish the config: `php artisan vendor:publish --tag=mail-blocks-config`.
2. Open `config/mail-blocks.php` and adjust:
    - `brand.name`, `brand.tagline` - company name and tagline (defaults to `config('app.name')`).
    - `layout.header` - logo URL, background, text color, badge label.
    - `layout.footer` - primary and secondary text, CTA label/link, `support_email`.
3. If you use custom Blade files, change `layout.header.view` / `layout.footer.view`.

### Overriding Blade templates

[](#overriding-blade-templates)

1. Publish the views: `php artisan vendor:publish --tag=mail-blocks-views`.
2. Edit files in `resources/views/vendor/mail-blocks`:
    - `layout.blade.php` - page shell (background, container, box shadow, spacing).
    - `partials/header.blade.php` / `partials/footer.blade.php` - hero and footer blocks.
    - `components/*.blade.php` - individual component markup.
3. Update the markup to match your brand: change colors, add social icons, unsubscribe links, etc. Header/footer already render the current year and fall back to `app.name`, but you can alter this logic freely.
4. Need a different directory? Point `layout.header.view` / `layout.footer.view` at your own Blade files.

Creating custom components
--------------------------

[](#creating-custom-components)

```
namespace App\Mail\Components;

use MailBlocks\Components\Component;
use MailBlocks\Traits\RendersBlade;

class Alert extends Component
{
    use RendersBlade;

    public function __construct(private string $title, private string $message) {}

    public static function make(string $title, string $message): static
    {
        return new static($title, $message);
    }

    public function render(): string
    {
        return $this->renderBlade('mail.components.alert', [
            'title' => $this->title,
            'message' => $this->message,
        ]);
    }
}
```

`resources/views/mail/components/alert.blade.php`:

```

            {{ $title }}
            {{ $message }}

```

Use it like any built-in component:

```
Alert::make('Heads up', 'We detected unusual activity.')->marginTop(24);
```

Recipes (ready-to-use templates)
--------------------------------

[](#recipes-ready-to-use-templates)

The `Examples` folder contains several scenarios you can copy and adapt. Jump straight to the source on GitHub:

FileUse case[Examples/ShowcaseComposerExample.php](https://github.com/lywebdev/laravel-mailblocks/blob/main/Examples/ShowcaseComposerExample.php)Marketing digest on `MailComposer`.[Examples/WelcomeExampleTemplate.php](https://github.com/lywebdev/laravel-mailblocks/blob/main/Examples/WelcomeExampleTemplate.php)Simple welcome message with hero + CTA.[Examples/CustomWelcomeTemplate.php](https://github.com/lywebdev/laravel-mailblocks/blob/main/Examples/CustomWelcomeTemplate.php)Advanced `MailTemplate` built with Box/Grid/Row.[Examples/Recipes/WelcomeHero.php](https://github.com/lywebdev/laravel-mailblocks/blob/main/Examples/Recipes/WelcomeHero.php)Hero layout with two CTAs.[Examples/Recipes/ProductLaunch.php](https://github.com/lywebdev/laravel-mailblocks/blob/main/Examples/Recipes/ProductLaunch.php)Product launch announcement with columns.[Examples/Recipes/OrderReceipt.php](https://github.com/lywebdev/laravel-mailblocks/blob/main/Examples/Recipes/OrderReceipt.php)Transactional receipt showcasing `Table`.[Examples/Recipes/EventAnnouncement.php](https://github.com/lywebdev/laravel-mailblocks/blob/main/Examples/Recipes/EventAnnouncement.php)Webinar/event announcement with info block.[Examples/Recipes/ChangelogDigest.php](https://github.com/lywebdev/laravel-mailblocks/blob/main/Examples/Recipes/ChangelogDigest.php)Weekly changelog digest using Box + Table.Tips
----

[](#tips)

- For fixed-width columns inside `Row`, wrap content with `Box::make()->containerWidth(200)->verticalGap(12)`.
- Use `Column::verticalCenter()` / `verticalBottom()` to align grid cells vertically.
- `grid([...], $gap)` uses padding, which renders reliably in Outlook.
- `containerWidth()` targets the wrapper table; `width()` targets the actual content inside the component.
- Need full control over visuals? Publish the Blade templates and edit `resources/views/vendor/mail-blocks/layout.blade.php` (plus header/footer) just like any regular email theme.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance47

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ea5787a46880ecc1a93d7331bfa6627d587b5a878351ca65833b5d0de712fa43?d=identicon)[lywebdev](/maintainers/lywebdev)

---

Top Contributors

[![lywebdev](https://avatars.githubusercontent.com/u/97740870?v=4)](https://github.com/lywebdev "lywebdev (15 commits)")

### Embed Badge

![Health badge](/badges/lywebdev-laravel-mailblocks/health.svg)

```
[![Health](https://phpackages.com/badges/lywebdev-laravel-mailblocks/health.svg)](https://phpackages.com/packages/lywebdev-laravel-mailblocks)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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