https://github.com/sendgrid/smtpapi-php
SendGrid's smtpapi library in PHP
https://github.com/sendgrid/smtpapi-php
Last synced: 7 months ago
JSON representation
SendGrid's smtpapi library in PHP
- Host: GitHub
- URL: https://github.com/sendgrid/smtpapi-php
- Owner: sendgrid
- License: mit
- Created: 2013-12-27T23:48:01.000Z (about 12 years ago)
- Default Branch: main
- Last Pushed: 2023-04-10T00:15:45.000Z (almost 3 years ago)
- Last Synced: 2024-11-09T12:41:29.861Z (over 1 year ago)
- Language: PHP
- Homepage: https://sendgrid.com
- Size: 335 KB
- Stars: 69
- Watchers: 201
- Forks: 63
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README

[](https://github.com/sendgrid/smtpapi-php/actions/workflows/test-and-deploy.yml)
[](https://packagist.org/packages/sendgrid/smtpapi)
[](https://packagist.org/packages/sendgrid/smtpapi )
[](https://twitter.com/sendgrid)
[](https://github.com/sendgrid/smtpapi-php/graphs/contributors)
[](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
All the updates to this module are documented in our [CHANGELOG](CHANGELOG.md).
# 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)
## 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
The following recommended installation requires [composer](http://getcomposer.org).
Add the following to your `composer.json` file.
```json
{
"require": {
"sendgrid/smtpapi": "^0.7.0"
}
}
```
Then at the top of your script require the autoloader:
```bash
require 'vendor/autoload.php';
```
#### 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:
```php
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
### Environment Variable
Update the development environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys), for example:
```bash
echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env
```
```php
$header = new Smtpapi\Header();
$header->addTo('test1@example.com');
$header->addTo('test2@example.com');
print $header->jsonString();
```
- [Twilio SendGrid Docs](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html)
- [Example Code](examples)
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)
smtpapi-php is maintained and funded by Twilio SendGrid, Inc. The names and logos for smtpapi-php are trademarks of Twilio SendGrid, Inc.
If you need help using SendGrid, please check the [Twilio SendGrid Support Help Center](https://support.sendgrid.com).