PHPackages                             aslamhus/sendgrid-email-wrapper - 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. aslamhus/sendgrid-email-wrapper

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

aslamhus/sendgrid-email-wrapper
===============================

a fluent interface for the SendGrid API v3, providing methods for constructing and sending emails with features such as dynamic template data, attachments, and various content types

v1.0.1(2y ago)07MIT

Since Dec 24Compare

[ Source](https://github.com/aslamhus/email)[ Packagist](https://packagist.org/packages/aslamhus/sendgrid-email-wrapper)[ RSS](/packages/aslamhus-sendgrid-email-wrapper/feed)WikiDiscussions Synced yesterday

READMEChangelogDependencies (3)Versions (3)Used By (0)

Aslamhus\\Email PHP Class
=========================

[](#aslamhusemail-php-class)

Overview
--------

[](#overview)

This PHP Library, `Aslamhus/Email`, is convenient and flexible wrapper for interacting with the SendGrid API v3.0.0. It is designed to provide a fluent interface for sending emails via SendGrid, making it simple to integrate email functionality into your PHP projects. The class includes methods for composing and sending emails with features such as dynamic template data, attachments, and more.

Installation / Setup
--------------------

[](#installation--setup)

To use this class in your project, follow these steps:

1. Create an account with [Sendgrid](https://sendgrid.com).
2. Create an API Key in your new sendgrid account. In the sidebar of your dashboard, choose `EmailApi`, then select `Integration Guide` from the dropdown. Choose WebApi -&gt; Php, then create your api key. You do not need to install sendgrid through composer, installing this class will do that for you. The last step in the integration guide is to send a verification email. Before we do that, install the library.
3. Create a single sender identity. This will allow you to send emails from an authenticated email. In the sidebar choose `Sender Authentication`, then `Verify a Single Sender`. Follow the steps. You'll use this email in the `from` method when sending emails.
4. Install `Aslamhus/Email`

    ```
    composer require aslamhus/sendgrid-email-wrapper
    ```
5. Send verficiation email (optional)

    ```
    // add your api key
    $email = new Email('your-sendgrid-api-key');
    // make sure to add your single sender identity email and name
    $didSend = $email->sendVerifyIntegrationEmail(['verified@example.com', 'Verified User']);
    // $didSend will return true if everything is set up correctly.
    ```
6. Confirm verification. Go back to the integration guide in your Sendgrid account, and at the bottom of the page choose `Verify Integration`. You should get a confirmation that your integration was successful.

Usage
-----

[](#usage)

### Send basic email

[](#send-basic-email)

```
$email = new Email('your-sendgrid-api-key')
    ->setFrom('sender@example.com', 'Sender Name')
    ->addTo('recipient@example.com', 'Recipient Name')
    ->setSubject('Test email')
    ->addContent('text/plain', 'Hello world!')
    ->send();
```

### Send Email with dynamic template data

[](#send-email-with-dynamic-template-data)

Dynamic template data variables can be set using `handlebars` {{my\_var}}. For more info see

```
$email = new Email('your-sendgrid-api-key')
    ->setFrom('sender@example.com', 'Sender Name')
    ->addTo('recipient@example.com', 'Recipient Name')
    ->setSubject('Test email')
    ->setTemplateId('your-template-id')
    ->addDynamicTemplateDatas([
        'subject' => 'My dynamic template email'
        'name' => '2020-01-01',
        'link' => 'https://www.example.com',
    ])
    ->send();
```

### Additional Features

[](#additional-features)

- **Add Attachments:**

    ```
    $email->addAttachment('path/to/file.pdf', 'application/pdf', 'document.pdf');
    ```
- **Add Content:**

    ```
    $email->addContent('text/plain', 'This is the plain text content');
    $email->addContent('text/html', 'This is the HTML content');
    ```
- **Get email response:**

    ```
    // retrieve the response body, headers and status code after sending
    $response = $email->getResponse();
    print_r($response->headers());
    echo $response->statusCode()
    echo $response->body()
    ```

Resources
---------

[](#resources)

- [SendGrid PHP Library on GitHub](https://github.com/sendgrid/sendgrid-php/blob/main/USAGE.md)
- [SendGrid API Methods](https://github.com/sendgrid/sendgrid-php/blob/08514e75789f192c034fdcf18efe6d8b1a7c91da/lib/BaseSendGridClientInterface.php#L65)

Issues and Contributions
------------------------

[](#issues-and-contributions)

If you encounter any issues or would like to contribute to the development of this class, please visit the GitHub repository: [Aslamhus\\Email](https://github.com/aslamhus/Email).

Testing
-------

[](#testing)

To run tests on this library, follow these steps:

1. Set your sample.env file with the require fields, then rename sample.env to .env
2. Run tests

```
composer run test
```

License
-------

[](#license)

This class is open-source and released under the [MIT License](LICENSE). Feel free to use, modify, and distribute it according to your project's needs.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~3 days

Total

2

Last Release

919d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/76789892?v=4)[Aslam](/maintainers/aslamhus)[@aslamhus](https://github.com/aslamhus)

---

Top Contributors

[![aslamhus](https://avatars.githubusercontent.com/u/76789892?v=4)](https://github.com/aslamhus "aslamhus (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aslamhus-sendgrid-email-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/aslamhus-sendgrid-email-wrapper/health.svg)](https://phpackages.com/packages/aslamhus-sendgrid-email-wrapper)
```

###  Alternatives

[swiftmade/laravel-sendgrid-notification-channel

Laravel Notification Channel for Sengrid.com

27319.1k](/packages/swiftmade-laravel-sendgrid-notification-channel)[iandenh/cakephp-sendgrid

SendgridEmail plugin for CakePHP

16126.1k](/packages/iandenh-cakephp-sendgrid)[bryglen/yii2-sendgrid

Sendgrid Mailer for Yii 2

1353.7k](/packages/bryglen-yii2-sendgrid)

PHPackages © 2026

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