Skip to content

Instantly share code, notes, and snippets.

@nanasess
Created January 26, 2017 16:54
Show Gist options
  • Save nanasess/85efc121ba4e9abdbe25ecbdbca6b887 to your computer and use it in GitHub Desktop.
Save nanasess/85efc121ba4e9abdbe25ecbdbca6b887 to your computer and use it in GitHub Desktop.
<?php
// using SendGrid's PHP Library
// https://github.com/sendgrid/sendgrid-php
// If you are using Composer (recommended)
require 'vendor/autoload.php';
// If you are not using Composer
// require("path/to/sendgrid-php/sendgrid-php.php");
$apiKey = getenv('SENDGRID_APIKEY');
$sg = new \SendGrid($apiKey);
$request_body = json_decode('{
"from": {
"email": "[email protected]",
"name": "こだわりん"
},
"personalizations": [
{
"bcc": [
{
"email": "[email protected]",
"name": "こだわりん"
}
],
"to": [
{
"email": "'."[email protected]".'",
"name": "森鷗外"
}
]
}
],
"categories": [
"customer_register",
"transaction"
],
"reply_to": {
"email": "[email protected]",
"name": "こだわりん"
},
"template_id": "8b0e3576-xxxx-xxxx-91ec-bf3dff4d16ec"
}');
$response = $sg->client->mail()->send()->post($request_body);
dump($response->statusCode());
dump($response->body());
dump($response->headers());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment