PHPackages                             devlab-studio/laravel-mailer - 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. devlab-studio/laravel-mailer

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

devlab-studio/laravel-mailer
============================

This is my package laravel-mailer

1.0.13(2mo ago)155MITPHPPHP ^8.3CI failing

Since Mar 19Pushed 2mo agoCompare

[ Source](https://github.com/devlab-studio/laravel-mailer)[ Packagist](https://packagist.org/packages/devlab-studio/laravel-mailer)[ Docs](https://github.com/devlab-studio/laravel-mailer)[ GitHub Sponsors](https://github.com/Devlab)[ RSS](/packages/devlab-studio-laravel-mailer/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (19)Versions (15)Used By (0)

 [ ![Devlab Logo](https://camo.githubusercontent.com/6313273fb35f1ad9a9fd1b33bcc7a5803c7147f6e5b6a7e9797c4cc4b130b04b/68747470733a2f2f6465762d6c61622e65732f6173736574732f6c6f676f732f6d61696e2d6c696768742e737667) ](https://dev-lab.es)

 [![Español](https://camo.githubusercontent.com/493bbce836760fc1c7c7e031d4efff413652f76ac1b9e88b6ba8914e14b81cb8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f457370612543332542316f6c2d566572253230656e25323045532d626c75652e7376673f7374796c653d666c61742d737175617265)](README.es.md)

Laravel Mailer
==============

[](#laravel-mailer)

Laravel package for advanced email sending with support for multiple SMTP senders, email logging and attachment management.

Summary
-------

[](#summary)

- Registers a custom channel to send notifications via SMTP configured per sender.
- Persists sent emails (body, metadata, status) and attachments to the database and storage (`storage/app/attachments/...`).
- Allows configuring SMTP senders via an interactive command or using `.env` and a seeder.

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

[](#installation)

Install via Composer:

```
composer require devlab-studio/laravel-mailer
```

Publish configuration (if applicable) and run migrations:

```
php artisan vendor:publish --tag=laravel-mailer-config
php artisan migrate
```

SMTP Configuration (.env)
-------------------------

[](#smtp-configuration-env)

Before using the package, fill in your SMTP credentials in `.env` or use the interactive command:

- `MAIL_MAILER=smtp`
- `MAIL_HOST=your.smtp.host`
- `MAIL_PORT=587`
- `MAIL_USERNAME=your@smtp.user`
- `MAIL_PASSWORD=secret`
- `MAIL_ENCRYPTION=tls` # tls, ssl or null
- `MAIL_FROM_ADDRESS=from@example.com`
- `MAIL_FROM_NAME="Your Name"`

Or run the interactive setup (it will save runtime config and run the seeder):

```
php artisan laravel-mailer
```

The command will ask for host, port, protocol, user, password, sender address and name and will run `EmailSendersTableSeeder`.

Senders Seeder
--------------

[](#senders-seeder)

The `EmailSendersTableSeeder` inserts a sender into the `email_senders` table using current `mail` configuration (normally from `.env`). Run it manually:

```
php artisan db:seed --class=\\Devlab\\LaravelMailer\\Database\\Seeders\\EmailSendersTableSeeder
```

File: database/seeders/EmailSendersTableSeeder.php

Custom channel and send flow
----------------------------

[](#custom-channel-and-send-flow)

The main channel is `CustomMailChannel` (`src/CustomMail/CustomMailChannel.php`) and does the following:

- Retrieves the recipient from the `notifiable`. Supports `AnonymousNotifiable`.
- Resolves the sender (`from`) from the message or from config (`devlab.MAIL_FROM_ADDRESS`).
- Logs the email in the `emails` table storing HTML body, subject, to/cc/bcc and metadata.
- Stores attachments in `storage/app/attachments/YYYY/M/D/` and creates records in `emails_attachments`.
- Selects which mailer to use by querying `email_senders` table:
    - If the sender exists, it dynamically creates a mailer `custom{ID}` with the sender credentials (password decrypted) and uses it.
    - Otherwise it falls back to the default `smtp` mailer.
- Sends the message using the selected mailer and updates the email record with status, sent date and errors if any.

Key files:

- `src/CustomMail/CustomMailChannel.php`
- `src/Models/Email.php` (logging and filters)
- `src/Models/EmailsAttachment.php` (attachment metadata)
- `src/Models/EmailSender.php` (SMTP senders)

Database structure
------------------

[](#database-structure)

The package includes migrations in `database/migrations` to create:

- `email_senders` — SMTP senders and credentials (password encrypted)
- `emails` — records of sent emails (body, status, to/cc/bcc, sent\_at, etc.)
- `emails_attachments` — attachment metadata and storage paths

Check `database/migrations` for exact columns.

Attachments storage
-------------------

[](#attachments-storage)

Physical attachments are copied to `storage/app/attachments/{year}/{month}/{day}/` and the path is recorded in the DB. The channel supports:

- `Illuminate\\Mail\\Attachment`
- `Illuminate\\Http\\UploadedFile`
- Disk paths (strings)

Usage (quick example)
---------------------

[](#usage-quick-example)

Inside a notification, implement `toCustomMail()` and return a `Mailable` or `MailMessage` with attachments and rawAttachments when needed. When notifying, the package:

```
// Notification
public function toCustomMail($notifiable)
{
    $mailable = new \\Illuminate\\Mail\\Mailable();
    // configure view, subject, attachments, etc.
    return $mailable;
}

// Send
$user->notify(new \\App\\Notifications\\MyNotification());
```

Errors and logging
------------------

[](#errors-and-logging)

On exception during sending, the channel captures the error, stores it on the email record and writes to the application log:

- Look for logs with `Log::error('CustomMailChannel error: ...')`

Best practices &amp; security
-----------------------------

[](#best-practices--security)

- Ensure SMTP credentials stored in the database are encrypted (the seeder uses `encrypt()` during insert).
- Protect access to `email_senders` if users can modify senders.

Useful commands
---------------

[](#useful-commands)

```
# Interactive setup and run seeder
php artisan laravel-mailer

# Run only the seeder
php artisan db:seed --class=\\Devlab\\LaravelMailer\\Database\\Seeders\\EmailSendersTableSeeder

# Run migrations (if not yet executed)
php artisan migrate
```

Package entry file
------------------

[](#package-entry-file)

The service provider registers config, migrations and the command:

- `src/LaravelMailerServiceProvider.php`

Support
-------

[](#support)

- Site:

---

© 2026 Devlab Studio

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance86

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

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

Every ~2 days

Total

14

Last Release

74d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97740b846ae0e3a38a14e6aea1701bf9020c976a91a99d5fa26ea62f194c442d?d=identicon)[devlab-studio](/maintainers/devlab-studio)

---

Top Contributors

[![Maizcur](https://avatars.githubusercontent.com/u/120595740?v=4)](https://github.com/Maizcur "Maizcur (14 commits)")[![rsimonru](https://avatars.githubusercontent.com/u/7046520?v=4)](https://github.com/rsimonru "rsimonru (12 commits)")

---

Tags

laravellaravel-mailerDevlab

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/devlab-studio-laravel-mailer/health.svg)

```
[![Health](https://phpackages.com/badges/devlab-studio-laravel-mailer/health.svg)](https://phpackages.com/packages/devlab-studio-laravel-mailer)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M42](/packages/spatie-laravel-pdf)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24855.3k](/packages/vormkracht10-laravel-mails)[filament/support

Core helper methods and foundation code for all Filament packages.

2328.3M218](/packages/filament-support)[nasirkhan/laravel-starter

A CMS like modular Laravel starter project.

1.4k2.7k](/packages/nasirkhan-laravel-starter)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.2k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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