Skip to content

Commit

Permalink
Merge branch 'master' into dynamic-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkingserious authored Aug 7, 2018
2 parents 4d6191b + 5fc6e1b commit 9215649
Show file tree
Hide file tree
Showing 82 changed files with 4,058 additions and 2,782 deletions.
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.txt)
[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)
[![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/sendgrid-php.svg)](https://github.com/sendgrid/sendgrid-php/graphs/contributors)
[![Open Source Helpers](https://www.codetriage.com/sendgrid/sendgrid-php/badges/users.svg)](https://www.codetriage.com/sendgrid/sendgrid-php)

**NEW:** Subscribe to email [notifications](https://dx.sendgrid.com/newsletter/php) for releases and breaking changes.

Expand Down Expand Up @@ -91,8 +92,12 @@ The following is the minimum needed code to send an email. You may find more exa
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// Comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$email = new \SendGrid\Mail\Mail();
$email->setFrom("[email protected]", "Example User");
Expand All @@ -109,7 +114,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage() ."\n";
}
```

Expand All @@ -121,8 +126,13 @@ The `SendGrid\Mail` constructor creates a [personalization object](https://sendg
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// Comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
Expand All @@ -133,7 +143,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage(). "\n";
}
```

Expand All @@ -143,8 +153,13 @@ try {
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// Comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
Expand All @@ -155,7 +170,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage(). "\n";
}
```

Expand Down
8 changes: 6 additions & 2 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ This documentation is based on our [OAI specification](https://github.com/sendgr
```php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// Comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
Expand Down
148 changes: 96 additions & 52 deletions USE_CASES.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
This documentation provides examples for specific use cases. Please [open an issue](https://github.com/sendgrid/sendgrid-php/issues) or make a pull request for any use cases you would like us to document here. Thank you!

# Table of Contents
* [Email - Attachments](#attachments)
* [Email - Kitchen Sink - an example with all settings used](#kitchen-sink)
* [Email - Send an Email to a Single Recipient](#single-email-single-recipient)
* [Email - Send an Email to Multiple Recipients](#single-email-multiple-recipients)
* [Email - Send Multiple Emails to Multiple Recipients](#multiple-emails-multiple-recipients)
* [Email - Transactional Templates](#transactional-templates)
* [How to Setup a Domain Whitelabel](#domain-whitelabel)
* [How to View Email Statistics](#email-stats)
* [Deploying to Heroku](#heroku)
* [Google App Engine Installation](#GAE-instructions)
- [Table of Contents](#table-of-contents)
- [Attachments](#attachments)
- [Kitchen Sink - an example with all settings used](#kitchen-sink---an-example-with-all-settings-used)
- [Send an Email to a Single Recipient](#send-an-email-to-a-single-recipient)
- [Send an Email to Multiple Recipients](#send-an-email-to-multiple-recipients)
- [Send Multiple Emails to Multiple Recipients](#send-multiple-emails-to-multiple-recipients)
- [Transactional Templates](#transactional-templates)
- [How to Setup a Domain Whitelabel](#how-to-setup-a-domain-whitelabel)
- [How to View Email Statistics](#how-to-view-email-statistics)
- [Deploying to Heroku](#deploying-to-heroku)
- [Google App Engine Installation](#google-app-engine-installation)

<a name="attachments"></a>
# Attachments
Expand All @@ -20,9 +21,13 @@ Here is an example of attaching a text file to your email, assuming that text fi
```php
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$email = new \SendGrid\Mail\Mail();
$email->setFrom("[email protected]", "Example User");
Expand All @@ -48,7 +53,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage(). "\n";
}
```

Expand All @@ -58,9 +63,13 @@ try {
```php
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$email = new \SendGrid\Mail\Mail();

Expand Down Expand Up @@ -235,7 +244,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage(). "\n";
}
```

Expand All @@ -244,9 +253,13 @@ OR
```php
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$email = new \SendGrid\Mail\Mail();

Expand Down Expand Up @@ -474,7 +487,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage(). "\n";
}
```

Expand All @@ -484,9 +497,13 @@ try {
```php
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$email = new \SendGrid\Mail\Mail();
$email->setFrom("[email protected]", "Example User");
Expand All @@ -503,7 +520,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage(). "\n";
}
```

Expand All @@ -512,9 +529,14 @@ OR
```php
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$from = new \SendGrid\Mail\From("[email protected]", "Example User");
$subject = new \SendGrid\Mail\Subject("Sending with SendGrid is Fun");
$to = new \SendGrid\Mail\To("[email protected]", "Example User");
Expand All @@ -538,7 +560,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage(). "\n";
}
```

Expand All @@ -548,9 +570,14 @@ try {
```php
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$email = new \SendGrid\Mail\Mail();
$email->setFrom("[email protected]", "Example User");
$tos = [
Expand All @@ -571,7 +598,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage(). "\n";
}
```

Expand All @@ -580,10 +607,13 @@ OR
```php
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line

// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases
$from = new \SendGrid\Mail\From("[email protected]", "Example User");
$tos = [
new \SendGrid\Mail\To("[email protected]", "Example User1"),
Expand Down Expand Up @@ -612,7 +642,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage(). "\n";
}
```

Expand All @@ -622,9 +652,14 @@ try {
```php
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$from = new \SendGrid\Mail\From("[email protected]", "Example User");
$tos = [
new \SendGrid\Mail\To(
Expand Down Expand Up @@ -680,7 +715,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage(). "\n";
}
```

Expand All @@ -689,9 +724,14 @@ OR
```php
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$from = new \SendGrid\Mail\From("[email protected]", "Example User");
$tos = [
new \SendGrid\Mail\To(
Expand Down Expand Up @@ -750,7 +790,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage(). "\n";
}
```

Expand Down Expand Up @@ -794,9 +834,13 @@ I hope you are having a great day in -city- :)
```php
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// comment out the above line if not using Composer
// require("./sendgrid-php.php");
// If not using Composer, uncomment the above line
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

use \SendGrid\Mail\From as From;
use \SendGrid\Mail\To as To;
Expand Down Expand Up @@ -854,7 +898,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage(). "\n";
}
```

Expand Down Expand Up @@ -901,7 +945,7 @@ try {
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'Caught exception: '. $e->getMessage(). "\n";
}
```

Expand Down
Loading

0 comments on commit 9215649

Please sign in to comment.