PHPackages                             yozaz/laravel-swiftmailer - 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. yozaz/laravel-swiftmailer

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

yozaz/laravel-swiftmailer
=========================

Laravel and SwiftMailer integration fix for Queued deamon workers

v4.0.3(9y ago)2471.5k↓45.2%3MITPHPPHP &gt;=5.4.0

Since Mar 30Pushed 9y ago2 watchersCompare

[ Source](https://github.com/YOzaz/Laravel-SwiftMailer)[ Packagist](https://packagist.org/packages/yozaz/laravel-swiftmailer)[ RSS](/packages/yozaz-laravel-swiftmailer/feed)WikiDiscussions master Synced 1mo ago

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

Laravel and Swift Mailer integrator
===================================

[](#laravel-and-swift-mailer-integrator)

[![Latest Stable Version](https://camo.githubusercontent.com/9da7e6f48d79c4f33154b850f7a04194f3ee3ddeb6aee3f1c3220d012943908f/68747470733a2f2f706f7365722e707567782e6f72672f594f7a617a2f4c61726176656c2d53776966744d61696c65722f762f737461626c652e737667)](https://packagist.org/packages/yozaz/laravel-swiftmailer)[![Total Downloads](https://camo.githubusercontent.com/61c15d4be8cff6db42574552c23bc898ced0567cffdbc2dd60cb8ec2148ae2b4/68747470733a2f2f706f7365722e707567782e6f72672f594f7a617a2f4c61726176656c2d53776966744d61696c65722f646f776e6c6f6164732e737667)](https://packagist.org/packages/yozaz/laravel-swiftmailer)[![License](https://camo.githubusercontent.com/8f84fc4e509ba7ed2f6ee74b04619411cbd4c44f57b81fe9499e4294ee394a6b/68747470733a2f2f706f7365722e707567782e6f72672f594f7a617a2f4c61726176656c2d53776966744d61696c65722f6c6963656e73652e737667)](https://packagist.org/packages/yozaz/laravel-swiftmailer)

WAS Deprecated...
-----------------

[](#was-deprecated)

This package was deprecated, as starting from Laravel 5.0 and above, original Mail class automatically theoretically reconnects on every message. See commit here: \[Force reconnection to fix mailing on daemon queues\] ().

However, it looks like just calling `stop` on a transport doesn't do full reset, therefore may throw an error - see discussion here: [laravel/framework#4573 (comment)](https://github.com/laravel/framework/issues/4573#issuecomment-211889196)

---

Package, which tries to solve long-term daemon worker issue. For reference:

- [swiftmailer/swiftmailer#490](https://github.com/swiftmailer/swiftmailer/issues/490)
- [laravel/framework#4573](https://github.com/laravel/framework/issues/4573)

Compatible with Laravel 4th and 5th versions.

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

[](#installation)

Begin by installing this package through Composer. Edit your project's `composer.json` file to require `yozaz/laravel-swiftmailer`.

```
"require": {
	"yozaz/laravel-swiftmailer": "~4.0"
}
```

Next, update Composer from the Terminal:

```
composer update
```

Once this operation completes, the next step is to add the service provider. Open `app/config/app.php` (or `config/app.php`), and add a new item to the providers array.

```
'YOzaz\LaravelSwiftmailer\ServiceProvider',
```

The final step is to replace Laravel's native Mailer Facade with the one, provided in a package. Open `app/config/app.php` (or `config/app.php`), and replace "Mail" alias with:

```
'Mail' => 'YOzaz\LaravelSwiftmailer\Facade',
```

That's it! You're all set to go.

About
-----

[](#about)

This package works in two possible error-safe modes: sends STOP command after every email is sent, and/or sends RESET/STOP+START commands before every email is sent. As a default, both modes are activated (so called "aggressive" mode). Such approach ensures SMTP connection is closed to avoid timeouts and broken pipes, or maintains it active for whole application living cycle. This is extremely important for long-living applications. E.g. when emails are sent through [Beanstalkd](https://github.com/kr/beanstalkd) + [Supervisor](http://supervisord.org/) + [Laravel Queue Daemon Worker](http://laravel.com/docs/4.2/queues#daemon-queue-worker) architecture, Laravel application never quits - therefore SMTP connection is kept active and timeouts after some time. Stopping, resetting and/or restarting SMTP connection automaticaly solves this problem in general.

**N.B.** While auto-reset feature is great, sometimes it's not a preferred behaviour. Be sure to check your SMTP server configuration before using this package.

Usage
-----

[](#usage)

Package is built in a way, that nothing special needs to be done. It's basically a wrapper, so all `Mailer::send()` and similar functions will work out of the box.

### Auto-reset

[](#auto-reset)

Package starts, stops or resets SMTP adapter every time when email is sent. You can manipulate this through special helper functions:

```
// disable auto reset
Mailer::disableAutoReset();
// enable it back
Mailer::enableAutoReset();
// Set my status
Mailer::setAutoReset(true);
// check if auto-reset is enabled
if ( Mailer::autoResetEnabled() ) { ...
```

You can switch between STOP or RESET behaviours using native constants as a flag:

```
// send only STOP after every email
Mailer::setModeStop();
// send only RESET before every email
Mailer::setModeReset();
// aggressive mode - STOP and RESET (default)
Mailer::setModeBoth();
```

It is possible to stop or reset SMTP adapter explicitly.

```
Mailer::reset()->send(...);
Mailer::stop();
```

### Silent mode

[](#silent-mode)

By default, failed emails will throw an `Exception`. If that's unexpected behaviour - e.g. because you don't need retry sending it - you can turn this mode on.

```
Mailer::setSilent(true);
```

**N.B.** Even if email will fail, before carrying over an `Exception`, package will try sending STOP command anyway (if such mode is enabled).

### Initialization

[](#initialization)

Package has separate IoC binding. **N.B.** This package *does not* overwrite 'mailer' IoC binding in Laravel for legacy purposes.

```
var $mailer = App::make('laravel-swiftmailer.mailer');
```

If you prefer object initialization against Facades, you can instantiate `Mailer` class by yourself, with additional parameters if required. Package will try to instantiate required objects automatically as defaults.

```
var $mailer = new \YOzaz\LaravelSwiftmailer\Mailer();
```

Optinally, if you have custom wrapper for Laravel's Mailer, or want to manipulate with auto-reset functionality, you can pass additional parameters to IoC binding or class instantiation. Take a look at class constructor for details.

```
var $my_custom_mailer = App::make('mailer');
// pass custom mailer and disable auto-reset
var $mailer = new \YOzaz\LaravelSwiftmailer\Mailer( $my_custom_mailer, false );
```

### Setting custom mailer instance

[](#setting-custom-mailer-instance)

To set custom mailer instance, call this method:

```
Mailer::setMailer( $my_custom_mailer );
```

Credits
-------

[](#credits)

All credits go to [xdecock](https://github.com/xdecock), author of [Swift Mailer](https://github.com/xdecock/swiftmailer), for providing ready-made solution implemented in this package.

License
-------

[](#license)

Laravel-SwiftMailer package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~41 days

Recently: every ~75 days

Total

18

Last Release

3360d ago

Major Versions

v1.2 → 2.22015-03-31

v2.4 → v3.02015-03-31

2.5 → v3.12015-03-31

v3.2.3 → v4.0.02017-02-27

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5859318?v=4)[Marijus Plančiūnas](/maintainers/YOzaz)[@YOzaz](https://github.com/YOzaz)

---

Top Contributors

[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")

---

Tags

laravelmailerphpsmtp-connectionswiftmailerlaravelmailqueuebeanstalkdswiftmailer

### Embed Badge

![Health badge](/badges/yozaz-laravel-swiftmailer/health.svg)

```
[![Health](https://phpackages.com/badges/yozaz-laravel-swiftmailer/health.svg)](https://phpackages.com/packages/yozaz-laravel-swiftmailer)
```

###  Alternatives

[propaganistas/laravel-disposable-email

Disposable email validator

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

A Laravel package to catch outbound mail (similar to Mailtrap) that also provides a UI to view them.

318.5k](/packages/modernmcguire-mailthief)

PHPackages © 2026

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