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(2mo ago)510.1k↑170%2MITPHPPHP &gt;=7.4CI passing

Since Jan 8Pushed 2mo 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 1mo 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

50

—

FairBetter than 96% of packages

Maintenance87

Actively maintained with recent releases

Popularity31

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

63d 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

[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[laravel-notification-channels/fcm

FCM (Firebase Cloud Messaging) Notifications Driver for Laravel

5917.0M16](/packages/laravel-notification-channels-fcm)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[laravel-notification-channels/aws-sns

Amazon Simple Notification Service (AWS SNS) notification channel for Laravel.

541.1M2](/packages/laravel-notification-channels-aws-sns)

PHPackages © 2026

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