PHPackages                             timfeid/slack-laravel-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. timfeid/slack-laravel-mail

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

timfeid/slack-laravel-mail
==========================

Laravel Mail driver that delivers mail to your Slack server

2.0.2(7y ago)13.9kMITPHP

Since May 16Pushed 7y ago1 watchersCompare

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

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

[![alt text](https://raw.githubusercontent.com/timfeid/slack-laravel-mail/master/image.png)](https://raw.githubusercontent.com/timfeid/slack-laravel-mail/master/image.png)

Set up
======

[](#set-up)

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

[](#installation)

`composer require timfeid/slack-laravel-mail`

Add `TimFeid\SlackLaravelMail\SlackMailServiceProvider::class,` to your providers list in your `app.php` config.

```
    TimFeid\SlackLaravelMail\SlackMailServiceProvider::class,
```

Config
------

[](#config)

Add the following config to your `services.php` config file.

```
    'slackmail' => [
        // The endpoint to your webhook
        'endpoint' => env('SLACKMAIL_ENDPOINT', 'https://hooks.slack.com/services/..../....'),
        // The driver for which you would like to store emails
        // Drivers are 'cache' and 'file' for now
        'driver' => env('SLACKMAIL_DRIVER', 'cache'),
        // Cache settings, will always use your default cache driver for now
        'cache' => [
            // Remove if you would not like to use cache()->tags()
            'tag' => 'slack-mail',
            // Time you want to keep emails for in minutes
            'ttl' => 60,
        ],
        'file' => [
            // File location you would like to save your emails
            'location' => storage_path('/mail'),
        ],
        // From user for your Slack message
        'from' => 'Emails',
        // Channel you'd like to send your messages to
        // @username to send private messages from @Slackbot
        'channel' => env('SLACKMAIL_TO', '#emails'),
        // Fields you would like to show up in your message
        'fields' => [
            'subject',
            'to',
            'cc',
            'bcc',
            'from',
            'attachments',
        ],
    ],
```

### Dot File (.env)

[](#dot-file-env)

As you can probably tell, .env is encouraged for a per-environment setup

```
    SLACKMAIL_ENDPOINT="https://hooks.slack.com/services..."
    SLACKMAIL_DRIVER="cache"
    SLACKMAIL_TO="@username"

    MAIL_DRIVER="slack" # Activate slackmail as your mail driver

```

Route
-----

[](#route)

Add this route to your routes file. The route can be set up however you'd like, but it *must* have `slackmail` as the name `->name('slackmail')`

```
    if (!app()->environment('production')) {
        Route::get('/slack-mail/{name}', '\TimFeid\SlackLaravelMail\Controllers\SlackMailController@slackMail')
            ->name('slackmail');
    }
```

### Extending the `fields`

[](#extending-the-fields)

You'll want to create service provider that extends `SlackMailServiceProvider` and overwrite the `registerSlackFields` method.

```
