An open API service indexing awesome lists of open source software.

https://github.com/pod-point/laravel-mail-export

A simple mailable trait and interface to export mails to a storage disk once being sent.
https://github.com/pod-point/laravel-mail-export

archive backup laravel mail storage

Last synced: 3 months ago
JSON representation

A simple mailable trait and interface to export mails to a storage disk once being sent.

Awesome Lists containing this project

README

          

# Laravel Mail Export

[![Latest Version on Packagist](https://img.shields.io/packagist/v/pod-point/laravel-mail-export.svg?style=flat-square)](https://packagist.org/packages/pod-point/laravel-mail-export)
[![tests](https://github.com/Pod-Point/laravel-mail-export/actions/workflows/run-tests.yml/badge.svg?branch=2.x)](https://github.com/Pod-Point/laravel-mail-export/actions/workflows/run-tests.yml)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Total Downloads](https://img.shields.io/packagist/dt/pod-point/laravel-mail-export.svg?style=flat-square)](https://packagist.org/packages/pod-point/laravel-mail-export)

This package can export any mail sent with Laravel's `Mailable` class to any desired filesystem disk and path as a `.eml` file.

This can be useful when wanting to store emails sent for archive purposes.

## Installation

You can install the package via composer:

For Laravel 9.x, 10.x, 11.x (requires PHP version 8.2 or higher)

```bash
composer require pod-point/laravel-mail-export
```

For Laravel 7.x and 8.x

```bash
composer require pod-point/laravel-mail-export:^1.0
```

For Laravel 5.x and 6.x

```bash
composer require pod-point/laravel-mail-export:^0.1
```

### Publishing the config file

The configuration for this package comes with some sensible values but you can optionally publish the config file with:

```bash
php artisan vendor:publish --provider="PodPoint\MailExport\MailExportServiceProvider"
```

You will be able to specify:

* `enabled`: whether this package is enabled or not. Once installed, it's enabled by default but the `MAIL_EXPORT` environment variable can be used to configure this.
* `disk`: which disk to use by default. `null` will use the default disk from your application filesystem.
* `path`: the default path, within the configured disk, where mail will be exported.

See our [`config/mail-export.php`](config/mail-export.php) for more details.

## Usage

Simply add the `Exportable` trait and the `ShouldExport` interface to any Mailable class that you want to persist into any storage disk.

```php
user())->send(new OrderShipped($order));
```

Even with Notifications too:

```php
order))->to($notifiable->email);
}
}
```

## Testing

Run the tests with:

```bash
composer test
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Credits

- [themsaid](https://github.com/themsaid) and Spatie's [laravel-mail-preview](https://github.com/spatie/laravel-mail-preview) for some inspiration
- [Laravel Package Development](https://laravelpackage.com) documentation by [John Braun](https://github.com/Jhnbrn90)
- [Pod Point](https://github.com/pod-point)
- [All Contributors](https://github.com/pod-point/laravel-mail-export/graphs/contributors)

## License

The MIT License (MIT). Please see [License File](LICENCE.md) for more information.

---

Travel shouldn't damage the earth 🌍

Made with ❤️  at [Pod Point](https://pod-point.com)