PHPackages                             datomatic/laravel-hubspot-email-notification-channel - 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. datomatic/laravel-hubspot-email-notification-channel

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

datomatic/laravel-hubspot-email-notification-channel
====================================================

Laravel Channel to save email and notifications on Hubspot Email

v1.5.1(3mo ago)512.0k↑290%2MITPHPPHP &gt;=7.4CI passing

Since Jan 8Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/datomatic/laravel-hubspot-email-notification-channel)[ Packagist](https://packagist.org/packages/datomatic/laravel-hubspot-email-notification-channel)[ Docs](https://github.com/datomatic/laravel-hubspot-email-notification-channel)[ GitHub Sponsors](https://github.com/Datomatic)[ RSS](/packages/datomatic-laravel-hubspot-email-notification-channel/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (16)Versions (15)Used By (0)

Hubspot Email Notifications Channel for Laravel
===============================================

[](#hubspot-email-notifications-channel-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e40ac958e693431870e709172f774ea99fe691468d1680fbc720e9fdf02878b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6461746f6d617469632f6c61726176656c2d68756273706f742d656d61696c2d6e6f74696669636174696f6e2d6368616e6e656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/datomatic/laravel-hubspot-email-notification-channel)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Quality Score](https://camo.githubusercontent.com/ca5ec3b9057d238eaa53a4e93f97111f58b118f6c43a7686d4f0dfc2951b30dd/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6461746f6d617469632f6c61726176656c2d68756273706f742d656d61696c2d6e6f74696669636174696f6e2d6368616e6e656c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/datomatic/laravel-hubspot-email-notification-channel)[![Total Downloads](https://camo.githubusercontent.com/28570621e38e971006446d179e65d394ca8b33ada71e7698bb958200ab2ddc1f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6461746f6d617469632f6c61726176656c2d68756273706f742d656d61696c2d6e6f74696669636174696f6e2d6368616e6e656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/datomatic/laravel-hubspot-email-notification-channel)

This package makes it easy to log notifications to [Hubspot Email Engagement V3](https://developers.hubspot.com/docs/api/crm/email) with Laravel &gt;= 8.x

Contents
--------

[](#contents)

- [Hubspot Email Notifications Channel for Laravel](#hubspot-email-notifications-channel-for-laravel)
    - [Contents](#contents)
    - [Installation](#installation)
        - [Setting up the HubspotEmail service](#setting-up-the-hubspotemail-service)
    - [Usage](#usage)
        - [Email notification](#email-notification)
        - [Example](#example)
            - [Notification example](#notification-example)
            - [Model example](#model-example)
    - [Changelog](#changelog)
    - [Testing](#testing)
    - [Security](#security)
    - [Contributing](#contributing)
    - [Credits](#credits)
    - [License](#license)

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

[](#installation)

You can install the package via composer:

```
composer require datomatic/laravel-hubspot-email-notification-channel
```

### Setting up the HubspotEmail service

[](#setting-up-the-hubspotemail-service)

Generate an [API Key](https://knowledge.hubspot.com/integrations/how-do-i-get-my-hubspot-api-key)or a [Private App](https://developers.hubspot.com/docs/api/private-apps) from Hubspot. **Important!** From November 30th 2022 Hubspot will require you to use only private apps. If you have both API Key and Private App configured, to switch using only Private App just remove `HUBSPOT_API_KEY` from your .env file.

Configure your Hubspot API on .env

```
HUBSPOT_API_KEY=XXXXXXXX
# or
HUBSPOT_ACCESS_TOKEN=XXXXXXXX
HUBSPOT_OWNER_ID=XXX //an Hubspot owner id to save as email creator
```

To publish the config file to config/newsletter.php run:

```
php artisan vendor:publish --provider="Datomatic\LaravelHubspotEmailNotificationChannel\HubspotEmailServiceProvider"
```

This will publish a file hubspot.php in your config directory with the following contents:

```
// config/hubspot.php

return [
    'api_key' => env('HUBSPOT_API_KEY'),
    'access_token' => env('HUBSPOT_API_KEY'),
    'hubspot_owner_id' => env('HUBSPOT_OWNER_ID',null)
];
```

Usage
-----

[](#usage)

You can now use the channel in your `via()` method inside the Notification class.

#### Email notification

[](#email-notification)

Your Notification class must have toMail method. The package accepts: MailMessage lines notifications, MailMessage view notifications and Markdown mail notifications.

Data stored on Hubspot:

- Hubspot Contact Id =&gt; The Notifiable Model must have **getHubspotContactId(\\Illuminate\\Notifications\\Notification $notification)** function
- Send at timestamp
- subject
- mail text (the html of the email or the toHubspotTextMail method of notification)

### Example

[](#example)

#### Notification example

[](#notification-example)

```
use Datomatic\LaravelHubspotEmailNotificationChannel\HubspotEmailChannel;
use Illuminate\Notifications\Notification;

class OrderConfirmation extends Notification
{
    ...
    public function via($notifiable)
    {
        return ['mail', HubspotEmailChannel::class]];
    }

    public function toMail($notifiable)
    {
        $message = (new MailMessage)
            ->subject(__('order.order_confirm', ['code' => $this->order->code]));

        return $message->view(
            'emails.order', [
                'title' => __('order.order_confirm', ['code' => $this->order->code]),
                'order' => $this->order
            ]
        );
    }

    //Optional text method
    public function toHubspotTextMail($notifiable):string
    {
        return 'text of message to put on hubspot';
    }
    ...
}
```

#### Send text version of html email

[](#send-text-version-of-html-email)

An example of use of `toHubspotTextMail` method is to send the text version of the email.

```
use Soundasleep\Html2Text;
class OrderConfirmation extends Notification
{
    ...

    public function toHubspotTextMail(mixed $notifiable): string
    {
        return Html2Text::convert($this->toMail($notifiable)->render());
    }
}
```

#### Model example

[](#model-example)

```
namespace App\Models;

class User extends Authenticatable{
    ...
    public function getHubspotContactId(\Illuminate\Notifications\Notification $notification){
        return $this->hubspot_contact_id;
    }
    ...
}
```

#### Dynamic Contact Owner

[](#dynamic-contact-owner)

```
use Datomatic\LaravelHubspotEmailNotificationChannel\HubspotEmailChannel;
use Illuminate\Notifications\Notification;

class PersonalMessage extends Notification
{
    ...

    public function via($notifiable)
    {
        return ['mail', HubspotEmailChannel::class]];
    }

    public function toMail($notifiable)
    {
        $message = (new MailMessage)
            ->subject(__('messages.personal_subject'))
            ->from($this->employee->email, $this->employee->name)
            ->metadata('hubspot_owner_id', $this->employee->hubspot_owner_id);

        return $message->view(
            'messages.personal', [
                'title' => __('messages.personal_welcome', ['recipient' => $notifiable->name]),
                'employee' => $this->employee
            ]
        );
    }

    ...
}
```

Changelog
---------

[](#changelog)

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

Testing
-------

[](#testing)

```
$ composer test
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Contributing
------------

[](#contributing)

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

Credits
-------

[](#credits)

- [Alberto Peripolli](https://github.com/trippo)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance79

Regular maintenance activity

Popularity32

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.6% 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 ~117 days

Recently: every ~152 days

Total

14

Last Release

109d ago

Major Versions

0.1.1 → v1.0.02022-09-23

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/497169?v=4)[Alberto Peripolli](/maintainers/trippo)[@trippo](https://github.com/trippo)

---

Top Contributors

[![trippo](https://avatars.githubusercontent.com/u/497169?v=4)](https://github.com/trippo "trippo (40 commits)")[![xolf](https://avatars.githubusercontent.com/u/8250052?v=4)](https://github.com/xolf "xolf (5 commits)")[![sk4t0](https://avatars.githubusercontent.com/u/24701038?v=4)](https://github.com/sk4t0 "sk4t0 (4 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/datomatic-laravel-hubspot-email-notification-channel/health.svg)

```
[![Health](https://phpackages.com/badges/datomatic-laravel-hubspot-email-notification-channel/health.svg)](https://phpackages.com/packages/datomatic-laravel-hubspot-email-notification-channel)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M164](/packages/spatie-laravel-health)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[laravel-notification-channels/expo

Expo Notifications Channel for Laravel

67628.6k1](/packages/laravel-notification-channels-expo)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

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