PHPackages                             uglydawg/laravel-markdown-emails - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. uglydawg/laravel-markdown-emails

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

uglydawg/laravel-markdown-emails
================================

A Laravel package for generating emails using Markdown with dynamic content support

01.2k↓25%PHP

Since Jul 18Pushed 10mo agoCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

Laravel Markdown Emails
=======================

[](#laravel-markdown-emails)

A Laravel package for generating beautiful emails using Markdown with dynamic content support, styled buttons, and comprehensive security features.

Features
--------

[](#features)

- =� **Markdown to HTML Email Conversion**: Convert Markdown content to beautifully styled HTML emails
- &lt;� **Styled Button Components**: Pre-configured button types (Primary, Secondary, Success, Danger, Warning, Custom)
- =� **Security First**: Built-in XSS protection, URL validation, and CSS sanitization
- =�� **Database Integration**: Store and manage email templates in your database
- � **Laravel Integration**: Seamless integration with Laravel's mail system
- &lt;� **Dynamic Content**: Support for variable substitution and Blade templating
- > � **Well Tested**: Comprehensive test suite with Pest

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.0, 11.0, or 12.0
- League CommonMark 2.0+

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

[](#installation)

Install the package via Composer:

```
composer require uglydawg/laravel-markdown-emails
```

Publish the configuration and migration files:

```
php artisan vendor:publish --provider="uglydawg\LaravelMarkdownEmails\MarkdownEmailsServiceProvider"
```

Run the migrations:

```
php artisan migrate
```

Quick Start
-----------

[](#quick-start)

### 1. Create a Markdown Email Template

[](#1-create-a-markdown-email-template)

```
use uglydawg\LaravelMarkdownEmails\MarkdownEmail;

$email = MarkdownEmail::create([
    'name' => 'welcome-email',
    'subject' => 'Welcome to Our Platform!',
    'content' => '# Welcome!

Thank you for joining us. Click below to get started:

{{ primary_button }}

If you have questions, feel free to reach out.

Best regards,
The Team'
]);
```

### 2. Render and Send Email

[](#2-render-and-send-email)

```
use uglydawg\LaravelMarkdownEmails\MarkdownEmailRenderer;
use uglydawg\LaravelMarkdownEmails\Enums\ButtonType;

$renderer = new MarkdownEmailRenderer(config('markdown-emails'));

// Create buttons
$primaryButton = $renderer->createButton(
    'Get Started',
    'https://example.com/dashboard',
    ButtonType::PRIMARY
);

// Render the email
$html = $renderer->render($email, [
    'primary_button' => $primaryButton
]);

// Send using Laravel's mail system
Mail::html($html, function ($message) {
    $message->to('user@example.com')
            ->subject('Welcome to Our Platform!');
});
```

Button Types
------------

[](#button-types)

The package includes several pre-styled button types:

```
use uglydawg\LaravelMarkdownEmails\Enums\ButtonType;

// Available button types
ButtonType::PRIMARY    // Default primary action button
ButtonType::SECONDARY  // Secondary action button
ButtonType::SUCCESS    // Success/confirmation button
ButtonType::DANGER     // Destructive action button
ButtonType::WARNING    // Warning button
ButtonType::CUSTOM     // Custom styled button
```

### Button Usage Examples

[](#button-usage-examples)

```
// Create different button types
$primaryBtn = $renderer->createButton('Sign Up', '/signup', ButtonType::PRIMARY);
$secondaryBtn = $renderer->createButton('Learn More', '/about', ButtonType::SECONDARY);
$successBtn = $renderer->createButton('Confirm', '/confirm', ButtonType::SUCCESS);
$dangerBtn = $renderer->createButton('Delete Account', '/delete', ButtonType::DANGER);
$warningBtn = $renderer->createButton('Proceed with Caution', '/warning', ButtonType::WARNING);

// Use in your markdown template
$variables = [
    'signup_button' => $primaryBtn,
    'learn_more_button' => $secondaryBtn,
    'user_name' => 'John Doe'
];

$html = $renderer->render($emailTemplate, $variables);
```

Configuration
-------------

[](#configuration)

The package configuration file `config/markdown-emails.php` allows you to customize:

- Button styling for each button type
- Default email templates
- Markdown parsing options
- Security settings

### Button Styling Configuration

[](#button-styling-configuration)

```
'buttons' => [
    'primary' => [
        'background_color' => '#007bff',
        'text_color' => 'white',
        'padding' => '12px 24px',
        'border_radius' => '5px',
        'font_weight' => 'bold',
        'margin' => '10px 0',
    ],
    'custom' => [
        'background_color' => '#ff6b6b',
        'text_color' => '#ffffff',
        'padding' => '16px 32px',
        'border_radius' => '8px',
        'font_weight' => 'normal',
        'margin' => '15px 0',
    ]
]
```

Security Features
-----------------

[](#security-features)

This package includes comprehensive security protections:

### URL Validation

[](#url-validation)

- Blocks dangerous protocols: `javascript:`, `data:`, `vbscript:`, `file:`, `about:`
- Allows safe protocols: `https:`, `http:`, `mailto:`, `tel:`, relative paths, anchors
- Automatically replaces unsafe URLs with `#`

### CSS Sanitization

[](#css-sanitization)

- Prevents CSS injection in button styling
- Length limits on CSS values to prevent DoS attacks
- Whitelist-based approach for CSS properties

### XSS Protection

[](#xss-protection)

- HTML escaping for all user-provided content
- Safe rendering of dynamic variables
- Protection against script injection

Database Schema
---------------

[](#database-schema)

The package creates a `markdown_emails` table with the following structure:

ColumnTypeDescriptionidbigintPrimary keynamestringUnique template identifiersubjectstringEmail subject linecontenttextMarkdown contentcreated\_attimestampCreation timestampupdated\_attimestampLast update timestampTesting
-------

[](#testing)

Run the test suite:

```
# Run all tests
composer test

# Run tests with coverage
composer test-coverage

# Run tests in parallel
composer test-parallel
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Email Templates

[](#custom-email-templates)

You can create custom Blade templates for different email types:

```
// Create a custom template
$renderer = new MarkdownEmailRenderer(config('markdown-emails'));
$html = $renderer->render($email, $variables, 'custom-email-template');
```

### Extending Button Types

[](#extending-button-types)

Add custom button configurations in your config file:

```
'buttons' => [
    'brand' => [
        'background_color' => '#your-brand-color',
        'text_color' => 'white',
        'padding' => '14px 28px',
        'border_radius' => '6px',
        'font_weight' => '600',
        'margin' => '12px 0',
    ]
]
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please ensure that:

1. All tests pass: `composer test`
2. Code follows PSR-12 standards
3. New features include tests
4. Security considerations are addressed

License
-------

[](#license)

This package is open-sourced software licensed under the [GNU LGPL v3 license](LICENSE).

Security
--------

[](#security)

If you discover any security vulnerabilities, please send an email to the package maintainer. All security vulnerabilities will be promptly addressed.

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- Package Author
- All Contributors

---

**Made with d� for the Laravel community**

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity16

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/e805ac0b80dfbcd4684995834f474a5ffd848ed87e96c4cbfc0145546a5e2c8e?d=identicon)[uglydawg](/maintainers/uglydawg)

---

Top Contributors

[![uglydawg](https://avatars.githubusercontent.com/u/7563223?v=4)](https://github.com/uglydawg "uglydawg (7 commits)")

### Embed Badge

![Health badge](/badges/uglydawg-laravel-markdown-emails/health.svg)

```
[![Health](https://phpackages.com/badges/uglydawg-laravel-markdown-emails/health.svg)](https://phpackages.com/packages/uglydawg-laravel-markdown-emails)
```

###  Alternatives

[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[eduardokum/laravel-mail-auto-embed

Library for embed images in emails automatically

1702.0M5](/packages/eduardokum-laravel-mail-auto-embed)

PHPackages © 2026

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