PHPackages                             elfsundae/laravel-multi-mail - 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. elfsundae/laravel-multi-mail

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

elfsundae/laravel-multi-mail
============================

The missing multi-mail implementation for Laravel 5.3

1.0.0(9y ago)14777[1 issues](https://github.com/ElfSundae/laravel-multi-mail/issues)MITPHPPHP &gt;=5.6.4

Since Nov 28Pushed 9y ago3 watchersCompare

[ Source](https://github.com/ElfSundae/laravel-multi-mail)[ Packagist](https://packagist.org/packages/elfsundae/laravel-multi-mail)[ Docs](https://github.com/ElfSundae/laravel-multi-mail)[ RSS](/packages/elfsundae-laravel-multi-mail/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (3)Versions (8)Used By (0)

Laravel Multi Mail
==================

[](#laravel-multi-mail)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4bf328aa1db562956694e8270e424fdcee38efc0358acd76eef7dd09998dd6dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f456c6653756e6461652f6c61726176656c2d6d756c74692d6d61696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elfsundae/laravel-multi-mail)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/fe88407d85b1179d960ab08dfbdfbbc3b5c4f914e47dd02134503cfcfe31ea1c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f456c6653756e6461652f6c61726176656c2d6d756c74692d6d61696c2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/ElfSundae/laravel-multi-mail)[![StyleCI](https://camo.githubusercontent.com/500ac018ff21ba6a289316ff7e01027ab91c11f23d158f4ad94a4b394aa01eb3/68747470733a2f2f7374796c6563692e696f2f7265706f732f37343739303933312f736869656c64)](https://styleci.io/repos/74790931)[![SensioLabsInsight](https://camo.githubusercontent.com/1f8f07b6d72fa06b2e53d906ddaaf58bfe7cd461c0a20e746edf368c98c23cdb/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f65336338323961642d326561332d346634342d613362322d6465356664363037373065622e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/e3c829ad-2ea3-4f44-a3b2-de5fd60770eb)[![Quality Score](https://camo.githubusercontent.com/114d2d82aecd7f8314f01a30a29a828eec8ea3f7eb6e9bdadf904a4ace1160e0/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f456c6653756e6461652f6c61726176656c2d6d756c74692d6d61696c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ElfSundae/laravel-multi-mail)[![Code Coverage](https://camo.githubusercontent.com/6f9d1cff20bdc60fe094b0ec88516603133e39edcf0b74a6d51bbce3796df9cb/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f456c6653756e6461652f6c61726176656c2d6d756c74692d6d61696c2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ElfSundae/laravel-multi-mail/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/dc6e293a67d1b16f1bac531b78ea73defe7367e63712d6c8eeace7df3f5b74f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f456c6653756e6461652f6c61726176656c2d6d756c74692d6d61696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elfsundae/laravel-multi-mail)

This package provides a flexible way to assist you in extending the [Laravel](https://laravel.com) mail service, it is the missing multi-mail implementation for Laravel 5.3.

The Laravel mail service provides a number of elegant ways to send e-mails, such as `Mailer` (the `Mail` facade), `Mailable`, `MailableMailer`, and the new [`Mail Notification`](https://laravel.com/docs/5.3/notifications#mail-notifications). Before getting started using this package, make sure you have read the [official mail documentation](https://laravel.com/docs/mail). This package will not change the way you are already familiar with sending e-mails, but help you customize the Laravel mail service, such as managing multi mail drivers at runtime, handling messages that are ultimately sent.

- [Installation](#installation)
- [Architecture](#architecture)
- [Usage Examples](#usage-examples)
    - [Custom Mail Drivers](#custom-mail-drivers)
    - [Changing The Default Driver](#changing-the-default-driver)
    - [Processing The Final Messages](#processing-the-final-messages)
    - [Altering Driver For Mail Message](#altering-driver-for-mail-message)
    - [Resetting Swift Mailers](#resetting-swift-mailers)
- [License](#license)

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

[](#installation)

1. Install this package using the [Composer](https://getcomposer.org) manager:

    ```
    $ composer require elfsundae/laravel-multi-mail
    ```
2. **Replace** `Illuminate\Mail\MailServiceProvider::class` with `ElfSundae\Multimail\MailServiceProvider::class` in the `config/app.php` file.

Architecture
------------

[](#architecture)

- `ElfSundae\Multimail\Mailer` *(extends `Illuminate\Mail\Mailer`)*

    The `Mailer` class is the facade and the maincenter of the Laravel mail system, all sending tasks will be handled by this class. You may access it using the `Mail` facade or `app('mailer')` helper function, as well as the `Mailer` type-hint or dependency injection.
- `ElfSundae\Multimail\SwiftMailerManager`

    The `SwiftMailerManager` singleton manages all Swift Mailer instances and their corresponding Swift Transport instances for the `Mailer`, it creates, caches, resets or destroys them. Each Swift Mailer instance is identified by the driver name of its transporter, such as `smtp`, `mailgun`, etc. You may access the manager via `Mail::getSwiftMailerManager()`, `app('swift.manager')`, `SwiftMailerManager` type-hint or dependency injection.
- `ElfSundae\Multimail\MessageHelper`

    It provides several helper methods for operating the mail messages, such as getting domain names of the email addresses for the mail recipients.

Usage Examples
--------------

[](#usage-examples)

Below are several examples of usage. Remember, you can do any customization as you want.

### Custom Mail Drivers

[](#custom-mail-drivers)

Laravel ships with a handful of mail drivers, but you may want to write your own drivers to send emails via other mail services. Laravel makes it simple. By using the `extend` method of the `TransportManager` singleton, you can register a custom driver creator.

```
