PHPackages                             hepplerdotnet/laravel-mail-auto-embed - 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. hepplerdotnet/laravel-mail-auto-embed

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

hepplerdotnet/laravel-mail-auto-embed
=====================================

Library for embed images in emails automatically

012PHP

Since Apr 28Pushed 2mo agoCompare

[ Source](https://github.com/HepplerDotNet/laravel-mail-auto-embed)[ Packagist](https://packagist.org/packages/hepplerdotnet/laravel-mail-auto-embed)[ RSS](/packages/hepplerdotnet-laravel-mail-auto-embed/feed)WikiDiscussions master Synced today

READMEChangelog (2)DependenciesVersions (1)Used By (0)

[![Packagist](https://camo.githubusercontent.com/f1c635731222920222fe67c9911dd0a2311f62af2470f1ac708ef7507db74482/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f486570706c6572446f744e65742f6c61726176656c2d6d61696c2d6175746f2d656d6265642e7376673f7374796c653d666c61742d737175617265)](https://github.com/HepplerDotNet/laravel-mail-auto-embed)[![Packagist](https://camo.githubusercontent.com/7bdcc7b3e3ef5631cce5e64fdf19a5cd615474c9ce7ee034d06fd5de4fd606b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f486570706c6572446f744e65742f6c61726176656c2d6d61696c2d6175746f2d656d6265642e7376673f7374796c653d666c61742d737175617265)](https://github.com/HepplerDotNet/laravel-mail-auto-embed)[![Packagist](https://camo.githubusercontent.com/7f294cdf342ebb548bc72921aa07b31d6d12a730e4d064450661340c4d287455/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f486570706c6572446f744e65742f6c61726176656c2d6d61696c2d6175746f2d656d6265642e7376673f7374796c653d666c61742d737175617265)](https://github.com/HepplerDotNet/laravel-mail-auto-embed)[![GitHub Actions](https://camo.githubusercontent.com/e3ad0b160e0a940b5fb321c6da1be4ecfac575a3ba12ca827ec9e7d5f6b7109a/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e742e7376673f7374796c653d666c61742d7371756172652675726c3d6874747073253341253246253246616374696f6e732d62616467652e6174726f782e646576253246486570706c6572446f744e65742532466c61726176656c2d6d61696c2d6175746f2d656d6265642532466261646765)](https://actions-badge.atrox.dev/HepplerDotNet/laravel-mail-auto-embed/goto)[![GitHub forks](https://camo.githubusercontent.com/d2f056ab2ece62edc23fb06fa1eff55f67ffc6427b9361caf9328d79264abd41/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f486570706c6572446f744e65742f6c61726176656c2d6d61696c2d6175746f2d656d6265642e7376673f636f6c6f723d6c6967687467726579267374796c653d666c61742d737175617265)](https://github.com/HepplerDotNet/laravel-mail-auto-embed)

Laravel Mail Auto Embed
=======================

[](#laravel-mail-auto-embed)

Automatically parses your messages and embeds the images found into your mail, replacing the original online-version of the image.

Should work on Laravel 5.3+. Automatically tested for Laravel 5.4+ on PHP 7.0+.

Version Compatibility
---------------------

[](#version-compatibility)

LaravelPackage&gt; 9.x2.xInstall
-------

[](#install)

You can install the package via composer:

```
composer require HepplerDotNet/laravel-mail-auto-embed
```

This package uses Laravel 5.5 Package Auto-Discovery. For previous versions of Laravel, you need to add the following Service Provider:

```
$providers = [
    ...
    \HepplerDotNet\LaravelMailAutoEmbed\ServiceProvider::class,
    ...
 ];
```

Usage
-----

[](#usage)

Its use is very simple, you write your markdown normally:

```

@component('mail::message')

# Order Shipped

Your order has been shipped!

@component('mail::button', ['url' => $url])
View Order
@endcomponent

Purchased product:

![product](https://domain.com/products/product-1.png)

Thanks,
{{ config('app.name') }}
@endcomponent
```

When sending, it will replace the link that would normally be generated:

> ``

by an embedded inline attachment of the image:

> ``.

It works for raw html too:

```

```

If you do not want to use automatic embedding for specific images (because they are hosted elsewhere, if you want to use some kind of image tracker, etc.), simply add the attribute `data-skip-embed` in the image tag:

```

```

### Local resources

[](#local-resources)

For local resources that are not available publicly, use `file://` urls:

```

```

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

[](#configuration)

The defaults are set in `config/mail-auto-embed.php`. You can copy this file to your own config directory to modify the values using this command:

```
php artisan vendor:publish --provider="HepplerDotNet\LaravelMailAutoEmbed\ServiceProvider"
```

### Explicit embedding configuration

[](#explicit-embedding-configuration)

By default, images are embedded automatically, unless you add the `data-skip-embed` attribute.

You can also disable auto-embedding globally by setting the `MAIL_AUTO_EMBED`environment variable to `false`, or by modifying the `enabled` property in the published config. You can then enable embedding for individual images with the `data-auto-embed` attribute.

```
# .env
MAIL_AUTO_EMBED=false
```

```
return [
    /*
    |--------------------------------------------------------------------------
    | Mail auto embed
    |--------------------------------------------------------------------------
    |
    | If true, images will be automatically embedded.
    | If false, only images with the 'data-auto-embed' attribute will be embedded
    |
    */
    'enabled' => false,

    // …
];
```

```

```

### Base64 embedding

[](#base64-embedding)

If you prefer to use Base64 instead of inline attachments, you can do so by setting the `MAIL_AUTO_EMBED_METHOD` environment variable or the `method`config property to `base64`.

```
return [
    // …

    /*
    |--------------------------------------------------------------------------
    | Mail embed method
    |--------------------------------------------------------------------------
    |
    | Supported: "attachment", "base64"
    |
    */
    'method' => 'base64',
];
```

Note that it will increase the e-mail size, and that it won't be decoded by some e-mail clients such as Gmail.

Mixed embedding methods
-----------------------

[](#mixed-embedding-methods)

If you want to use both inline attachment and Base64 depending on the image, you can specify the embedding method as the `data-auto-embed` attribute value:

```

```

Embedding entities
------------------

[](#embedding-entities)

You might want to embed images that don't actually exist in your filesystem (stored in the database).

In that case, make the entities you want to embed implement the `EmbeddableEntity` interface:

```
namespace App\Models;

use HepplerDotNet\LaravelMailAutoEmbed\Models\EmbeddableEntity;
use Illuminate\Database\Eloquent\Model;

class Picture extends Model implements EmbeddableEntity
{
    /**
     * @param  mixed  $id
     * @return Picture
     */
    public static function findEmbeddable($id)
    {
        return static::find($id);
    }

    /**
     * @return mixed
     */
    public function getRawContent()
    {
        return $this->data;
    }

    /**
     * @return string
     */
    public function getFileName()
    {
        return 'profile_'.$this->id.'.png';
    }

    /**
     * @return string
     */
    public function getMimeType()
    {
        return 'image/png';
    }
}
```

Then, you can use the `embed:ClassName:id` syntax in your e-mail template:

```

```

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

[](#contributing)

Please feel free to submit pull requests if you can improve or add any features.

We are currently using PSR-2. This is easy to implement and check with the PHP Coding Standards Fixer.

[ ![Donate with Paypal](https://camo.githubusercontent.com/0293c3ea1e6dbe13508306375f69c8d21d79fce0478eb6f60e84c512d7e5192c/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f47422f692f62746e2f62746e5f646f6e61746543435f4c472e676966)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=QPDFT3UXS6PTL&lc=GB&item_name=laravel%2dmail%2dauto%2dembed&item_number=laravel%2dmail%2dauto%2dembed&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance57

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 68.9% 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://avatars.githubusercontent.com/u/12952240?v=4)[Patrick Heppler](/maintainers/HepplerDotNet)[@HepplerDotNet](https://github.com/HepplerDotNet)

---

Top Contributors

[![eduardokum](https://avatars.githubusercontent.com/u/2566340?v=4)](https://github.com/eduardokum "eduardokum (82 commits)")[![Djuuu](https://avatars.githubusercontent.com/u/2388233?v=4)](https://github.com/Djuuu "Djuuu (11 commits)")[![okaufmann](https://avatars.githubusercontent.com/u/4414498?v=4)](https://github.com/okaufmann "okaufmann (10 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (4 commits)")[![shaffe-fr](https://avatars.githubusercontent.com/u/3834222?v=4)](https://github.com/shaffe-fr "shaffe-fr (2 commits)")[![sdapkus](https://avatars.githubusercontent.com/u/58326108?v=4)](https://github.com/sdapkus "sdapkus (2 commits)")[![HepplerDotNet](https://avatars.githubusercontent.com/u/12952240?v=4)](https://github.com/HepplerDotNet "HepplerDotNet (2 commits)")[![patrick-heppler](https://avatars.githubusercontent.com/u/69577537?v=4)](https://github.com/patrick-heppler "patrick-heppler (2 commits)")[![nmfzone](https://avatars.githubusercontent.com/u/10361906?v=4)](https://github.com/nmfzone "nmfzone (1 commits)")[![ilvalerione](https://avatars.githubusercontent.com/u/13559278?v=4)](https://github.com/ilvalerione "ilvalerione (1 commits)")[![amenk](https://avatars.githubusercontent.com/u/1087128?v=4)](https://github.com/amenk "amenk (1 commits)")[![rubenvanassche](https://avatars.githubusercontent.com/u/619804?v=4)](https://github.com/rubenvanassche "rubenvanassche (1 commits)")

### Embed Badge

![Health badge](/badges/hepplerdotnet-laravel-mail-auto-embed/health.svg)

```
[![Health](https://phpackages.com/badges/hepplerdotnet-laravel-mail-auto-embed/health.svg)](https://phpackages.com/packages/hepplerdotnet-laravel-mail-auto-embed)
```

###  Alternatives

[maize-tech/laravel-email-domain-rule

Laravel Email Domain Rule

612.0k](/packages/maize-tech-laravel-email-domain-rule)

PHPackages © 2026

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