PHPackages                             sendgrid/smtpapi - 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. sendgrid/smtpapi

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

sendgrid/smtpapi
================

Build SendGrid X-SMTPAPI headers in PHP.

0.7.0(4y ago)696.5M—3.7%54[2 PRs](https://github.com/sendgrid/smtpapi-php/pulls)2MITPHPPHP &gt;=7.3

Since Jan 1Pushed 3y ago191 watchersCompare

[ Source](https://github.com/sendgrid/smtpapi-php)[ Packagist](https://packagist.org/packages/sendgrid/smtpapi)[ Docs](https://github.com/sendgrid/smtpapi-php)[ RSS](/packages/sendgrid-smtpapi/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (21)Used By (2)

[![Twilio SendGrid Logo](twilio_sendgrid_logo.png)](twilio_sendgrid_logo.png)

[![BuildStatus](https://github.com/sendgrid/smtpapi-php/actions/workflows/test-and-deploy.yml/badge.svg)](https://github.com/sendgrid/smtpapi-php/actions/workflows/test-and-deploy.yml)[![Latest Stable Version](https://camo.githubusercontent.com/27eb34608dc4c9e3d7b453ae4673533ca633a0f2b8ec486851f9a7c5084e5aa9/68747470733a2f2f706f7365722e707567782e6f72672f73656e64677269642f736d74706170692f76657273696f6e2e706e67)](https://packagist.org/packages/sendgrid/smtpapi)[![Latest Version on Packagist](https://camo.githubusercontent.com/7ab1af2cee154a60cdf104fc6cb55a82788f41e903ac3fd2522c543910220681/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73656e64677269642f736d74706170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sendgrid/smtpapi)[![Twitter Follow](https://camo.githubusercontent.com/de94c561669f318291c017e2043b37498ea2f8820d5f35be0af56fe149c1a793/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f73656e64677269642e7376673f7374796c653d736f6369616c266c6162656c3d466f6c6c6f77)](https://twitter.com/sendgrid)[![GitHub contributors](https://camo.githubusercontent.com/f03d56ea63176d9c9b1f24c521155875bfcabc13529beda5ea3db9d70bd00fe6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f73656e64677269642f736d74706170692d7068702e737667)](https://github.com/sendgrid/smtpapi-php/graphs/contributors)[![MIT licensed](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

**This module helps build Twilio SendGrid's SMTP API headers.**

Learn more about the SMTP API at [Twilio SendGrid's documentation](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html).

Announcements
=============

[](#announcements)

All the updates to this module are documented in our [CHANGELOG](CHANGELOG.md).

Table of Contents
=================

[](#table-of-contents)

- [Installation](#installation)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Announcements](#announcements)
- [How to Contribute](#how-to-contribute)
- [About](#about)
- [Support](#support)
- [License](#license)

Installation
============

[](#installation)

Prerequisites
-------------

[](#prerequisites)

- PHP version 7.3, 7.4, 8.0, or 8.1
- The Twilio SendGrid service, starting at the [free level](https://sendgrid.com/free?source=smtpapi-php)

Install with Composer
---------------------

[](#install-with-composer)

The following recommended installation requires [composer](http://getcomposer.org).

Add the following to your `composer.json` file.

```
{
    "require": {
        "sendgrid/smtpapi": "^0.7.0"
    }
}
```

Then at the top of your script require the autoloader:

```
require 'vendor/autoload.php';
```

#### Alternative: Install package from zip

[](#alternative-install-package-from-zip)

If you are not using Composer, simply download and install the **[latest packaged release of the library as a zip](https://github.com/sendgrid/smtpapi-php/releases/download/0.7.0/smtpapi-php.zip)**.

[**⬇︎ Download Packaged Library ⬇︎**](https://github.com/sendgrid/smtpapi-php/releases/download/0.7.0/smtpapi-php.zip)

Then require the library from package:

```
require('path/to/smtpapi-php/smtpapi-php.php');
```

The previous versions of the library can be downloaded directly from [GitHub](https://github.com/sendgrid/smtpapi-php/releases).

Setup Environment Variables
---------------------------

[](#setup-environment-variables)

### Environment Variable

[](#environment-variable)

Update the development environment with your [SENDGRID\_API\_KEY](https://app.sendgrid.com/settings/api_keys), for example:

```
echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env
```

Quick Start
===========

[](#quick-start)

```
$header = new Smtpapi\Header();
$header->addTo('test1@example.com');
$header->addTo('test2@example.com');
print $header->jsonString();
```

Usage
=====

[](#usage)

- [Twilio SendGrid Docs](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html)
- [Example Code](examples)

How to Contribute
-----------------

[](#how-to-contribute)

We encourage contributions to our projects; please see our [CONTRIBUTING](CONTRIBUTING.md) guide for details.

Quick links:

- [Feature Request](CONTRIBUTING.md#feature_request)
- [Bug Reports](CONTRIBUTING.md#submit_a_bug_report)
- [Improvements to the Codebase](CONTRIBUTING.md#improvements_to_the_codebase)
- [Review Pull Requests](CONTRIBUTING.md#code-reviews)

About
=====

[](#about)

smtpapi-php is maintained and funded by Twilio SendGrid, Inc. The names and logos for smtpapi-php are trademarks of Twilio SendGrid, Inc.

Support
=======

[](#support)

If you need help using SendGrid, please check the [Twilio SendGrid Support Help Center](https://support.sendgrid.com).

License
=======

[](#license)

[The MIT License (MIT)](LICENSE)

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity59

Moderate usage in the ecosystem

Community39

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor5

5 contributors hold 50%+ of commits

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 ~169 days

Recently: every ~28 days

Total

19

Last Release

1475d ago

PHP version history (3 changes)0.0.1PHP &gt;=5.3

0.6.0PHP &gt;=5.6

0.7.0PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/15c5d48ebf689d7036efb9c4848dba91aca5a696e18b5e738fe3702424a5072b?d=identicon)[twilio-dx](/maintainers/twilio-dx)

---

Top Contributors

[![thinkingserious](https://avatars.githubusercontent.com/u/146695?v=4)](https://github.com/thinkingserious "thinkingserious (30 commits)")[![motdotla](https://avatars.githubusercontent.com/u/3848?v=4)](https://github.com/motdotla "motdotla (22 commits)")[![twilio-ci](https://avatars.githubusercontent.com/u/15808651?v=4)](https://github.com/twilio-ci "twilio-ci (17 commits)")[![owenvoke](https://avatars.githubusercontent.com/u/1899334?v=4)](https://github.com/owenvoke "owenvoke (14 commits)")[![twilio-dx](https://avatars.githubusercontent.com/u/76711946?v=4)](https://github.com/twilio-dx "twilio-dx (14 commits)")[![eddiezane](https://avatars.githubusercontent.com/u/959573?v=4)](https://github.com/eddiezane "eddiezane (13 commits)")[![jmauerhan](https://avatars.githubusercontent.com/u/4204262?v=4)](https://github.com/jmauerhan "jmauerhan (11 commits)")[![eddytan](https://avatars.githubusercontent.com/u/6778749?v=4)](https://github.com/eddytan "eddytan (7 commits)")[![thepriefy](https://avatars.githubusercontent.com/u/10849586?v=4)](https://github.com/thepriefy "thepriefy (6 commits)")[![pushkyn](https://avatars.githubusercontent.com/u/3326427?v=4)](https://github.com/pushkyn "pushkyn (4 commits)")[![eshanholtz](https://avatars.githubusercontent.com/u/28262845?v=4)](https://github.com/eshanholtz "eshanholtz (4 commits)")[![nikoskip](https://avatars.githubusercontent.com/u/1230033?v=4)](https://github.com/nikoskip "nikoskip (3 commits)")[![nocategory](https://avatars.githubusercontent.com/u/12294525?v=4)](https://github.com/nocategory "nocategory (3 commits)")[![fishnux](https://avatars.githubusercontent.com/u/29991194?v=4)](https://github.com/fishnux "fishnux (3 commits)")[![awwa](https://avatars.githubusercontent.com/u/327181?v=4)](https://github.com/awwa "awwa (2 commits)")[![ssiddhantsharma](https://avatars.githubusercontent.com/u/29195354?v=4)](https://github.com/ssiddhantsharma "ssiddhantsharma (2 commits)")[![saputradharma](https://avatars.githubusercontent.com/u/45839696?v=4)](https://github.com/saputradharma "saputradharma (2 commits)")[![JenniferMah](https://avatars.githubusercontent.com/u/42650198?v=4)](https://github.com/JenniferMah "JenniferMah (2 commits)")[![yashasingh](https://avatars.githubusercontent.com/u/14851240?v=4)](https://github.com/yashasingh "yashasingh (1 commits)")[![gr8shivam](https://avatars.githubusercontent.com/u/4292333?v=4)](https://github.com/gr8shivam "gr8shivam (1 commits)")

---

Tags

apiemailtwiliosendgridsendgridsmtpsmtpapixsmtpX-SMTP

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/sendgrid-smtpapi/health.svg)

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

###  Alternatives

[sendgrid/sendgrid

This library allows you to quickly and easily send emails through Twilio SendGrid using PHP.

1.5k47.5M164](/packages/sendgrid-sendgrid)[fastglass/sendgrid

This library allows you to send emails through SendGrid using PHP and Guzzle 6.x.

213.7M](/packages/fastglass-sendgrid)

PHPackages © 2026

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