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

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

theupriser/laravel-mail-auto-embed
==================================

Library for embed images in emails automatically

2.2(1y ago)033MITPHPPHP ^7.2|^8.0

Since Mar 6Pushed 1y agoCompare

[ Source](https://github.com/theupriser/laravel-mail-auto-embed)[ Packagist](https://packagist.org/packages/theupriser/laravel-mail-auto-embed)[ Docs](https://github.com/eduardokum/laravel-mail-auto-embed)[ GitHub Sponsors](https://github.com/eduardokum)[ RSS](/packages/theupriser-laravel-mail-auto-embed/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

[![Packagist](https://camo.githubusercontent.com/9374b859b89d9728145b2b01968435e5f07d170ad4f4f6bd457865345fd1868d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6564756172646f6b756d2f6c61726176656c2d6d61696c2d6175746f2d656d6265642e7376673f7374796c653d666c61742d737175617265)](https://github.com/eduardokum/laravel-mail-auto-embed)[![Packagist](https://camo.githubusercontent.com/4f59e3f8d8cab123e6183a98dfc3c97b0f78284d17dc3c92c058fbb3cc0a227b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6564756172646f6b756d2f6c61726176656c2d6d61696c2d6175746f2d656d6265642e7376673f7374796c653d666c61742d737175617265)](https://github.com/eduardokum/laravel-mail-auto-embed)[![Packagist](https://camo.githubusercontent.com/e172d325dad74c51c9ce025452a3fcef4914453d6a1d046a5adbe7c4106c0a7e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6564756172646f6b756d2f6c61726176656c2d6d61696c2d6175746f2d656d6265642e7376673f7374796c653d666c61742d737175617265)](https://github.com/eduardokum/laravel-mail-auto-embed)[![GitHub Actions](https://camo.githubusercontent.com/bd94e621801612b6d1e8511e49dd67b53e8a0e646401c40fe5cd254141393d03/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e742e7376673f7374796c653d666c61742d7371756172652675726c3d6874747073253341253246253246616374696f6e732d62616467652e6174726f782e6465762532466564756172646f6b756d2532466c61726176656c2d6d61696c2d6175746f2d656d6265642532466261646765)](https://actions-badge.atrox.dev/eduardokum/laravel-mail-auto-embed/goto)[![GitHub forks](https://camo.githubusercontent.com/e6c98b6b2fd5268b57a331eb2cc1c62464047f45089f3a724e5b61e65d854d21/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6564756172646f6b756d2f6c61726176656c2d6d61696c2d6175746f2d656d6265642e7376673f636f6c6f723d6c6967687467726579267374796c653d666c61742d737175617265)](https://github.com/eduardokum/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&lt; 8.x1.x&gt; 9.x2.xInstall
-------

[](#install)

You can install the package via composer:

```
composer require eduardokum/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 = [
    ...
    \Eduardokum\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="Eduardokum\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 Eduardokum\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

28

—

LowBetter than 54% of packages

Maintenance45

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70.7% 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

Unknown

Total

1

Last Release

433d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/16fd65986cc1d73583eb6e7b995587aaa172b9ebfedbca90c6f20a0a873e6913?d=identicon)[theupriser](/maintainers/theupriser)

---

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)")[![shaffe-fr](https://avatars.githubusercontent.com/u/3834222?v=4)](https://github.com/shaffe-fr "shaffe-fr (2 commits)")[![theupriser](https://avatars.githubusercontent.com/u/5661837?v=4)](https://github.com/theupriser "theupriser (1 commits)")[![ilvalerione](https://avatars.githubusercontent.com/u/13559278?v=4)](https://github.com/ilvalerione "ilvalerione (1 commits)")[![nmfzone](https://avatars.githubusercontent.com/u/10361906?v=4)](https://github.com/nmfzone "nmfzone (1 commits)")[![rubenvanassche](https://avatars.githubusercontent.com/u/619804?v=4)](https://github.com/rubenvanassche "rubenvanassche (1 commits)")[![amenk](https://avatars.githubusercontent.com/u/1087128?v=4)](https://github.com/amenk "amenk (1 commits)")

---

Tags

eduardokumlaravel-mail-auto-embed

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[eduardokum/laravel-mail-auto-embed

Library for embed images in emails automatically

1702.0M5](/packages/eduardokum-laravel-mail-auto-embed)[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[mckenziearts/laravel-notify

Flexible flash notifications for Laravel

1.7k1.1M5](/packages/mckenziearts-laravel-notify)[fedeisas/laravel-mail-css-inliner

Inline the CSS of your HTML emails using Laravel

5974.6M3](/packages/fedeisas-laravel-mail-css-inliner)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[propaganistas/laravel-disposable-email

Disposable email validator

5762.6M6](/packages/propaganistas-laravel-disposable-email)

PHPackages © 2026

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