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

08PHP

Since Mar 7Pushed 1y 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 1mo ago

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

16

—

LowBetter than 5% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 Bus Factor1

Top contributor holds 69.5% 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/fac8ffb6e5e7e1aac30e253a8c56cc66e78c82235acf1520c85050253cc4a786?d=identicon)[HepplerDotNet](/maintainers/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)")[![sdapkus](https://avatars.githubusercontent.com/u/58326108?v=4)](https://github.com/sdapkus "sdapkus (2 commits)")[![patrick-heppler](https://avatars.githubusercontent.com/u/69577537?v=4)](https://github.com/patrick-heppler "patrick-heppler (2 commits)")[![shaffe-fr](https://avatars.githubusercontent.com/u/3834222?v=4)](https://github.com/shaffe-fr "shaffe-fr (2 commits)")[![nmfzone](https://avatars.githubusercontent.com/u/10361906?v=4)](https://github.com/nmfzone "nmfzone (1 commits)")[![HepplerDotNet](https://avatars.githubusercontent.com/u/12952240?v=4)](https://github.com/HepplerDotNet "HepplerDotNet (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

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M227](/packages/tijsverkoyen-css-to-inline-styles)[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)

PHPackages © 2026

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