Creating a custom sender | laravel-backup | Spatie

 SPATIE

  Laravel Backup
=================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-backup](https://spatie.be/docs/laravel-backup/v3)  Sending-notifications  Creating a custom sender

 Version   v10   v9   v8   v7   v6   v5   v4   v3

 Other versions for crawler [v10](https://spatie.be/docs/laravel-backup/v10) [v9](https://spatie.be/docs/laravel-backup/v9) [v8](https://spatie.be/docs/laravel-backup/v8) [v7](https://spatie.be/docs/laravel-backup/v7) [v6](https://spatie.be/docs/laravel-backup/v6) [v5](https://spatie.be/docs/laravel-backup/v5) [v4](https://spatie.be/docs/laravel-backup/v4) [v3](https://spatie.be/docs/laravel-backup/v3)

  Creating a custom sender
- [ Introduction ](https://spatie.be/docs/laravel-backup/v3/introduction)
- [ Postcardware ](https://spatie.be/docs/laravel-backup/v3/postcardware)
- [ Requirements ](https://spatie.be/docs/laravel-backup/v3/requirements)
- [ High level overview ](https://spatie.be/docs/laravel-backup/v3/high-level-overview)
- [ Installation and setup ](https://spatie.be/docs/laravel-backup/v3/installation-and-setup)
- [ Questions &amp; issues ](https://spatie.be/docs/laravel-backup/v3/questions-and-issues)
- [ Changelog ](https://spatie.be/docs/laravel-backup/v3/changelog)
- [ About us ](https://spatie.be/docs/laravel-backup/v3/about-us)

Taking Backups
--------------

- [ Taking backups ](https://spatie.be/docs/laravel-backup/v3/taking-backups/overview)
- [ Events ](https://spatie.be/docs/laravel-backup/v3/taking-backups/events)

Cleaning up old backups
-----------------------

- [ Cleaning up old backups ](https://spatie.be/docs/laravel-backup/v3/cleaning-up-old-backups/overview)
- [ Events ](https://spatie.be/docs/laravel-backup/v3/cleaning-up-old-backups/events)

Monitoring the health of all backups
------------------------------------

- [ Monitoring the health of all backups ](https://spatie.be/docs/laravel-backup/v3/monitoring-the-health-of-all-backups/overview)
- [ Events ](https://spatie.be/docs/laravel-backup/v3/monitoring-the-health-of-all-backups/events)

Sending notifications
---------------------

- [ Sending notifications ](https://spatie.be/docs/laravel-backup/v3/sending-notifications/overview)
- [ Creating a custom sender ](https://spatie.be/docs/laravel-backup/v3/sending-notifications/creating-a-custom-sender)

Advanced Usage
--------------

- [ Adding Extra Files to the zip ](https://spatie.be/docs/laravel-backup/v3/advanced-usage/adding-extra-files-to-the-zip)
- [ Backing up a non-laravel application ](https://spatie.be/docs/laravel-backup/v3/advanced-usage/backing-up-a-non-laravel-application)

      You are viewing the documentation for **an older version** of this package. You can check the version you are using with the following command:

 `                                    composer show spatie/laravel-backup                                                                                                                                                                                                                                    `

Creating a custom sender
========================

By default the backup package can notify you by:

- writing something in the log
- by sending a mail
- if `maknz/slack` is installed, posting a message on [Slack](https://slack.com)

If you want to be notified via another channel you can create your own sender. A valid sender is any object that implements the `Spatie\Backup\Notifications\SendsNotifications`-interface.

```
namespace Spatie\Backup\Notifications;

interface SendsNotifications
{
    /**
     * @param string $type
     *
     * @return \Spatie\Backup\Notifications\SendsNotifications
     */
    public function setType($type);

    /**
     * @param string $subject
     *
     * @return \Spatie\Backup\Notifications\SendsNotifications
     */
    public function setSubject($subject);

    /**
     * @param string $message
     *
     * @return \Spatie\Backup\Notifications\SendsNotifications
     */
    public function setMessage($message);

    public function send();
}
```

If you choose to extend `Spatie\Backup\Notifications\BaseSender` you'll only need to implement the `send`-function.

Your custom sender can be used by specifying it's full class name in one the `monitor.events`-keys in the laravel-backup config file.

```
// ...
'whenBackupHasFailed' => ['log', 'mail', App\Backup\MyCustomSender::class],
// ...
```

When you've created a sender that could be beneficial to the community, consider [contributing](https://github.com/spatie/laravel-backup/blob/master/CONTRIBUTING.md) the code to this package.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
