summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElmer Thomas <elmer@thinkingserious.com>2016-06-15 14:37:19 -0700
committerElmer Thomas <elmer@thinkingserious.com>2016-06-15 14:37:19 -0700
commit2e1d11fa7c145dbeecf31e4d1db59d3be47bc2a7 (patch)
tree4919a3288c5349ffc8cae02fb84b4a4e1cff72c3
parent1dd4de646cef60c0eca70c8fe8047909052fbf98 (diff)
downloadsendgrid-php-2e1d11fa7c145dbeecf31e4d1db59d3be47bc2a7.zip
sendgrid-php-2e1d11fa7c145dbeecf31e4d1db59d3be47bc2a7.tar.gz
sendgrid-php-2e1d11fa7c145dbeecf31e4d1db59d3be47bc2a7.tar.bz2
Update Documentation and Examples
-rw-r--r--USAGE.md479
-rw-r--r--examples/mail/mail.php143
2 files changed, 312 insertions, 310 deletions
diff --git a/USAGE.md b/USAGE.md
index d88960c..35ec703 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -77,10 +77,10 @@ $request_body = json_decode('{
"ips": [
{
"ip": "192.168.1.1"
- },
+ },
{
"ip": "192.*.*.*"
- },
+ },
{
"ip": "192.168.1.3/32"
}
@@ -124,8 +124,8 @@ For more information, please see our [User Guide](http://sendgrid.com/docs/User_
```php
$request_body = json_decode('{
"ids": [
- 1,
- 2,
+ 1,
+ 2,
3
]
}');
@@ -194,10 +194,10 @@ See the [API Key Permissions List](https://sendgrid.com/docs/API_Reference/Web_A
```php
$request_body = json_decode('{
- "name": "My API Key",
+ "name": "My API Key",
"scopes": [
- "mail.send",
- "alerts.create",
+ "mail.send",
+ "alerts.create",
"alerts.read"
]
}');
@@ -236,9 +236,9 @@ The API Keys feature allows customers to be able to generate an API Key credenti
```php
$request_body = json_decode('{
- "name": "A New Hope",
+ "name": "A New Hope",
"scopes": [
- "user.profile.read",
+ "user.profile.read",
"user.profile.update"
]
}');
@@ -333,8 +333,8 @@ Each user can create up to 25 different suppression groups.
```php
$request_body = json_decode('{
- "description": "Suggestions for products our users might like.",
- "is_default": true,
+ "description": "Suggestions for products our users might like.",
+ "is_default": true,
"name": "Product Suggestions"
}');
$response = $sg->client->asm()->groups()->post($request_body);
@@ -373,8 +373,8 @@ Each user can create up to 25 different suppression groups.
```php
$request_body = json_decode('{
- "description": "Suggestions for items our users might like.",
- "id": 103,
+ "description": "Suggestions for items our users might like.",
+ "id": 103,
"name": "Item Suggestions"
}');
$group_id = "test_url_param";
@@ -439,7 +439,7 @@ Suppressions are recipient email addresses that are added to [unsubscribe groups
```php
$request_body = json_decode('{
"recipient_emails": [
- "test1@example.com",
+ "test1@example.com",
"test2@example.com"
]
}');
@@ -509,7 +509,7 @@ A global suppression (or global unsubscribe) is an email address of a recipient
```php
$request_body = json_decode('{
"recipient_emails": [
- "test1@example.com",
+ "test1@example.com",
"test2@example.com"
]
}');
@@ -571,7 +571,7 @@ echo $response->headers();
<a name="browsers"></a>
# BROWSERS
-## Retrieve email statistics by browser.
+## Retrieve email statistics by browser.
**This endpoint allows you to retrieve your email statistics segmented by browser type.**
@@ -611,21 +611,21 @@ For more information:
$request_body = json_decode('{
"categories": [
"spring line"
- ],
- "custom_unsubscribe_url": "",
- "html_content": "<html><head><title></title></head><body><p>Check out our spring line!</p></body></html>",
- "ip_pool": "marketing",
+ ],
+ "custom_unsubscribe_url": "",
+ "html_content": "<html><head><title></title></head><body><p>Check out our spring line!</p></body></html>",
+ "ip_pool": "marketing",
"list_ids": [
- 110,
+ 110,
124
- ],
- "plain_content": "Check out our spring line!",
+ ],
+ "plain_content": "Check out our spring line!",
"segment_ids": [
110
- ],
- "sender_id": 124451,
- "subject": "New Products for Spring!",
- "suppression_group_id": 42,
+ ],
+ "sender_id": 124451,
+ "subject": "New Products for Spring!",
+ "suppression_group_id": 42,
"title": "March Newsletter"
}');
$response = $sg->client->campaigns()->post($request_body);
@@ -670,10 +670,10 @@ For more information:
$request_body = json_decode('{
"categories": [
"summer line"
- ],
- "html_content": "<html><head><title></title></head><body><p>Check out our summer line!</p></body></html>",
- "plain_content": "Check out our summer line!",
- "subject": "New Products for Summer!",
+ ],
+ "html_content": "<html><head><title></title></head><body><p>Check out our summer line!</p></body></html>",
+ "plain_content": "Check out our summer line!",
+ "subject": "New Products for Summer!",
"title": "May Newsletter"
}');
$campaign_id = "test_url_param";
@@ -871,7 +871,7 @@ echo $response->headers();
If you do not define any query parameters, this endpoint will return a sum for each category in groups of 10.
-Categories allow you to group your emails together according to broad topics that you define. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/categories.html).
+Categories allow you to group your emails together according to broad topics that you define. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/categories.html).
### GET /categories/stats
@@ -889,7 +889,7 @@ echo $response->headers();
If you do not define any query parameters, this endpoint will return a sum for each category in groups of 10.
-Categories allow you to group your emails together according to broad topics that you define. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/categories.html).
+Categories allow you to group your emails together according to broad topics that you define. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/categories.html).
### GET /categories/stats/sums
@@ -961,7 +961,7 @@ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](
```php
$request_body = json_decode('{
- "name": "pet",
+ "name": "pet",
"type": "text"
}');
$response = $sg->client->contactdb()->custom_fields()->post($request_body);
@@ -971,7 +971,7 @@ echo $response->headers();
```
## Retrieve all custom fields
-**This endpoint allows you to retrieve all custom fields.**
+**This endpoint allows you to retrieve all custom fields.**
The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html).
@@ -1060,9 +1060,9 @@ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.co
```php
$request_body = json_decode('[
- 1,
- 2,
- 3,
+ 1,
+ 2,
+ 3,
4
]');
$response = $sg->client->contactdb()->lists()->delete($request_body);
@@ -1138,7 +1138,7 @@ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.co
```php
$request_body = json_decode('[
- "recipient_id1",
+ "recipient_id1",
"recipient_id2"
]');
$list_id = "test_url_param";
@@ -1149,7 +1149,7 @@ echo $response->headers();
```
## Retrieve all recipients on a List
-**This endpoint allows you to retrieve all recipients on the list with the given ID.**
+**This endpoint allows you to retrieve all recipients on the list with the given ID.**
The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients.
@@ -1215,8 +1215,8 @@ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](
```php
$request_body = json_decode('[
{
- "email": "jones@example.com",
- "first_name": "Guy",
+ "email": "jones@example.com",
+ "first_name": "Guy",
"last_name": "Jones"
}
]');
@@ -1239,15 +1239,15 @@ The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.co
```php
$request_body = json_decode('[
{
- "age": 25,
- "email": "example@example.com",
- "first_name": "",
+ "age": 25,
+ "email": "example@example.com",
+ "first_name": "",
"last_name": "User"
- },
+ },
{
- "age": 25,
- "email": "example2@example.com",
- "first_name": "Example",
+ "age": 25,
+ "email": "example2@example.com",
+ "first_name": "Example",
"last_name": "User"
}
]');
@@ -1288,7 +1288,7 @@ The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](
```php
$request_body = json_decode('[
- "recipient_id1",
+ "recipient_id1",
"recipient_id2"
]');
$response = $sg->client->contactdb()->recipients()->delete($request_body);
@@ -1429,14 +1429,14 @@ List Id:
* Send this to segment from an existing list
* Don't send this in order to segment from your entire contactdb.
-Valid operators for create and update depend on the type of the field you are segmenting:
+Valid operators for create and update depend on the type of the field you are segmenting:
-* **Dates:** "eq", "ne", "lt" (before), "gt" (after)
-* **Text:** "contains", "eq" (is - matches the full field), "ne" (is not - matches any field where the entire field is not the condition value)
-* **Numbers:** "eq", "lt", "gt"
-* **Email Clicks and Opens:** "eq" (opened), "ne" (not opened)
+* **Dates:** "eq", "ne", "lt" (before), "gt" (after)
+* **Text:** "contains", "eq" (is - matches the full field), "ne" (is not - matches any field where the entire field is not the condition value)
+* **Numbers:** "eq", "lt", "gt"
+* **Email Clicks and Opens:** "eq" (opened), "ne" (not opened)
-Segment conditions using "eq" or "ne" for email clicks and opens should provide a "field" of either *clicks.campaign_identifier* or *opens.campaign_identifier*. The condition value should be a string containing the id of a completed campaign.
+Segment conditions using "eq" or "ne" for email clicks and opens should provide a "field" of either *clicks.campaign_identifier* or *opens.campaign_identifier*. The condition value should be a string containing the id of a completed campaign.
Segments may contain multiple condtions, joined by an "and" or "or" in the "and_or" field. The first condition in the conditions list must have an empty "and_or", and subsequent conditions must all specify an "and_or".
@@ -1451,25 +1451,25 @@ For more information about segments in Marketing Campaigns, please see our [User
$request_body = json_decode('{
"conditions": [
{
- "and_or": "",
- "field": "last_name",
- "operator": "eq",
+ "and_or": "",
+ "field": "last_name",
+ "operator": "eq",
"value": "Miller"
- },
+ },
{
- "and_or": "and",
- "field": "last_clicked",
- "operator": "gt",
+ "and_or": "and",
+ "field": "last_clicked",
+ "operator": "gt",
"value": "01/02/2015"
- },
+ },
{
- "and_or": "or",
- "field": "clicks.campaign_identifier",
- "operator": "eq",
+ "and_or": "or",
+ "field": "clicks.campaign_identifier",
+ "operator": "eq",
"value": "513"
}
- ],
- "list_id": 4,
+ ],
+ "list_id": 4,
"name": "Last Name Miller"
}');
$response = $sg->client->contactdb()->segments()->post($request_body);
@@ -1509,13 +1509,13 @@ For more information about segments in Marketing Campaigns, please see our [User
$request_body = json_decode('{
"conditions": [
{
- "and_or": "",
- "field": "last_name",
- "operator": "eq",
+ "and_or": "",
+ "field": "last_name",
+ "operator": "eq",
"value": "Miller"
}
- ],
- "list_id": 5,
+ ],
+ "list_id": 5,
"name": "The Millers"
}');
$query_params = json_decode('{"segment_id": "test_string"}');
@@ -1915,7 +1915,7 @@ echo $response->headers();
**This endpoint allows you to generate a new batch ID. This batch ID can be associated with scheduled sends via the mail/send endpoint.**
-If you set the SMTPAPI header `batch_id`, it allows you to then associate multiple scheduled mail/send requests together with the same ID. Then at anytime up to 10 minutes before the schedule date, you can cancel all of the mail/send requests that have this batch ID by calling the Cancel Scheduled Send endpoint.
+If you set the SMTPAPI header `batch_id`, it allows you to then associate multiple scheduled mail/send requests together with the same ID. Then at anytime up to 10 minutes before the schedule date, you can cancel all of the mail/send requests that have this batch ID by calling the Cancel Scheduled Send endpoint.
More Information:
@@ -1934,7 +1934,7 @@ echo $response->headers();
**This endpoint allows you to validate a batch ID.**
-If you set the SMTPAPI header `batch_id`, it allows you to then associate multiple scheduled mail/send requests together with the same ID. Then at anytime up to 10 minutes before the schedule date, you can cancel all of the mail/send requests that have this batch ID by calling the Cancel Scheduled Send endpoint.
+If you set the SMTPAPI header `batch_id`, it allows you to then associate multiple scheduled mail/send requests together with the same ID. Then at anytime up to 10 minutes before the schedule date, you can cancel all of the mail/send requests that have this batch ID by calling the Cancel Scheduled Send endpoint.
More Information:
@@ -1950,7 +1950,7 @@ echo $response->statusCode();
echo $response->body();
echo $response->headers();
```
-## v3 Mail Send Beta
+## v3 Mail Send
This endpoint allows you to send email over SendGrids v3 Web API, the most recent version of our API. If you are looking for documentation about the v2 Mail Send endpoint, please see our [v2 API Reference](https://sendgrid.com/docs/API_Reference/Web_API/mail.html).
@@ -1961,154 +1961,155 @@ For an overview of the v3 Mail Send endpoint, please visit our [v3 API Reference
For more detailed information about how to use the v3 Mail Send endpoint, please visit our [Classroom](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/index.html).
-### POST /mail/send/beta
+### POST /mail/send
+This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-php/blob/master/lib/helpers/mail/README.md).
```php
$request_body = json_decode('{
"asm": {
- "group_id": 1,
+ "group_id": 1,
"groups_to_display": [
- 1,
- 2,
+ 1,
+ 2,
3
]
- },
+ },
"attachments": [
{
- "content": "[BASE64 encoded content block here]",
- "content_id": "ii_139db99fdb5c3704",
- "disposition": "inline",
- "filename": "file1.jpg",
- "name": "file1",
+ "content": "[BASE64 encoded content block here]",
+ "content_id": "ii_139db99fdb5c3704",
+ "disposition": "inline",
+ "filename": "file1.jpg",
+ "name": "file1",
"type": "jpg"
}
- ],
- "batch_id": "[YOUR BATCH ID GOES HERE]",
+ ],
+ "batch_id": "[YOUR BATCH ID GOES HERE]",
"categories": [
- "category1",
+ "category1",
"category2"
- ],
+ ],
"content": [
{
- "type": "text/html",
+ "type": "text/html",
"value": "<html><p>Hello, world!</p><img src=[CID GOES HERE]></img></html>"
}
- ],
+ ],
"custom_args": {
- "New Argument 1": "New Value 1",
- "activationAttempt": "1",
+ "New Argument 1": "New Value 1",
+ "activationAttempt": "1",
"customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
- },
+ },
"from": {
- "email": "sam.smith@example.com",
+ "email": "sam.smith@example.com",
"name": "Sam Smith"
- },
- "headers": {},
- "ip_pool_name": "[YOUR POOL NAME GOES HERE]",
+ },
+ "headers": {},
+ "ip_pool_name": "[YOUR POOL NAME GOES HERE]",
"mail_settings": {
"bcc": {
- "email": "ben.doe@example.com",
+ "email": "ben.doe@example.com",
"enable": true
- },
+ },
"bypass_list_management": {
"enable": true
- },
+ },
"footer": {
- "enable": true,
- "html": "<p>Thanks</br>The SendGrid Team</p>",
+ "enable": true,
+ "html": "<p>Thanks</br>The SendGrid Team</p>",
"text": "Thanks,/n The SendGrid Team"
- },
+ },
"sandbox_mode": {
"enable": false
- },
+ },
"spam_check": {
- "enable": true,
- "post_to_url": "http://example.com/compliance",
+ "enable": true,
+ "post_to_url": "http://example.com/compliance",
"threshold": 3
}
- },
+ },
"personalizations": [
{
"bcc": [
{
- "email": "sam.doe@example.com",
+ "email": "sam.doe@example.com",
"name": "Sam Doe"
}
- ],
+ ],
"cc": [
{
- "email": "jane.doe@example.com",
+ "email": "jane.doe@example.com",
"name": "Jane Doe"
}
- ],
+ ],
"custom_args": {
- "New Argument 1": "New Value 1",
- "activationAttempt": "1",
+ "New Argument 1": "New Value 1",
+ "activationAttempt": "1",
"customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
- },
+ },
"headers": {
- "X-Accept-Language": "en",
+ "X-Accept-Language": "en",
"X-Mailer": "MyApp"
- },
- "send_at": 1409348513,
- "subject": "Hello, World!",
+ },
+ "send_at": 1409348513,
+ "subject": "Hello, World!",
"substitutions": {
"sub": {
"%name%": [
- "John",
- "Jane",
+ "John",
+ "Jane",
"Sam"
]
}
- },
+ },
"to": [
{
- "email": "john.doe@example.com",
+ "email": "john.doe@example.com",
"name": "John Doe"
}
]
}
- ],
+ ],
"reply_to": {
- "email": "sam.smith@example.com",
+ "email": "sam.smith@example.com",
"name": "Sam Smith"
- },
+ },
"sections": {
"section": {
- ":sectionName1": "section 1 text",
+ ":sectionName1": "section 1 text",
":sectionName2": "section 2 text"
}
- },
- "send_at": 1409348513,
- "subject": "Hello, World!",
- "template_id": "[YOUR TEMPLATE ID GOES HERE]",
+ },
+ "send_at": 1409348513,
+ "subject": "Hello, World!",
+ "template_id": "[YOUR TEMPLATE ID GOES HERE]",
"tracking_settings": {
"click_tracking": {
- "enable": true,
+ "enable": true,
"enable_text": true
- },
+ },
"ganalytics": {
- "enable": true,
- "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]",
- "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]",
- "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]",
- "utm_name": "[NAME OF YOUR CAMPAIGN]",
+ "enable": true,
+ "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]",
+ "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]",
+ "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]",
+ "utm_name": "[NAME OF YOUR CAMPAIGN]",
"utm_term": "[IDENTIFY PAID KEYWORDS HERE]"
- },
+ },
"open_tracking": {
- "enable": true,
+ "enable": true,
"substitution_tag": "%opentrack"
- },
+ },
"subscription_tracking": {
- "enable": true,
- "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
- "substitution_tag": "<%click here%>",
+ "enable": true,
+ "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
+ "substitution_tag": "<%click here%>",
"text": "If you would like to unsubscribe and stop receiveing these emails <% click here %>."
}
}
}');
-$response = $sg->client->mail()->send()->beta()->post($request_body);
+$response = $sg->client->mail()->send()->post($request_body);
echo $response->statusCode();
echo $response->body();
echo $response->headers();
@@ -2145,9 +2146,9 @@ Mail settings allow you to tell SendGrid specific things to do to every email th
```php
$request_body = json_decode('{
- "enabled": true,
+ "enabled": true,
"list": [
- "email1@example.com",
+ "email1@example.com",
"example.com"
]
}');
@@ -2186,7 +2187,7 @@ Mail settings allow you to tell SendGrid specific things to do to every email th
```php
$request_body = json_decode('{
- "email": "email@example.com",
+ "email": "email@example.com",
"enabled": false
}');
$response = $sg->client->mail_settings()->bcc()->patch($request_body);
@@ -2224,8 +2225,8 @@ Mail settings allow you to tell SendGrid specific things to do to every email th
```php
$request_body = json_decode('{
- "enabled": true,
- "hard_bounces": 5,
+ "enabled": true,
+ "hard_bounces": 5,
"soft_bounces": 5
}');
$response = $sg->client->mail_settings()->bounce_purge()->patch($request_body);
@@ -2263,8 +2264,8 @@ Mail settings allow you to tell SendGrid specific things to do to every email th
```php
$request_body = json_decode('{
- "enabled": true,
- "html_content": "...",
+ "enabled": true,
+ "html_content": "...",
"plain_content": "..."
}');
$response = $sg->client->mail_settings()->footer()->patch($request_body);
@@ -2302,7 +2303,7 @@ Mail settings allow you to tell SendGrid specific things to do to every email th
```php
$request_body = json_decode('{
- "email": "example@example.com",
+ "email": "example@example.com",
"enabled": true
}');
$response = $sg->client->mail_settings()->forward_bounce()->patch($request_body);
@@ -2340,7 +2341,7 @@ Mail settings allow you to tell SendGrid specific things to do to every email th
```php
$request_body = json_decode('{
- "email": "",
+ "email": "",
"enabled": false
}');
$response = $sg->client->mail_settings()->forward_spam()->patch($request_body);
@@ -2415,8 +2416,8 @@ Mail settings allow you to tell SendGrid specific things to do to every email th
```php
$request_body = json_decode('{
- "enabled": true,
- "max_score": 5,
+ "enabled": true,
+ "max_score": 5,
"url": "url"
}');
$response = $sg->client->mail_settings()->spam_check()->patch($request_body);
@@ -2445,7 +2446,7 @@ echo $response->headers();
**This endpoint allows you to update your current legacy email template settings.**
-This setting refers to our original email templates. We currently support more fully featured [transactional templates](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
+This setting refers to our original email templates. We currently support more fully featured [transactional templates](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
The legacy email template setting wraps an HTML template around your email content. This can be useful for sending out marketing email and/or other HTML formatted messages.
@@ -2456,7 +2457,7 @@ Mail settings allow you to tell SendGrid specific things to do to every email th
```php
$request_body = json_decode('{
- "enabled": true,
+ "enabled": true,
"html_content": "<% body %>"
}');
$response = $sg->client->mail_settings()->template()->patch($request_body);
@@ -2468,7 +2469,7 @@ echo $response->headers();
**This endpoint allows you to retrieve your current legacy email template settings.**
-This setting refers to our original email templates. We currently support more fully featured [transactional templates](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
+This setting refers to our original email templates. We currently support more fully featured [transactional templates](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html).
The legacy email template setting wraps an HTML template around your email content. This can be useful for sending out marketing email and/or other HTML formatted messages.
@@ -2536,8 +2537,8 @@ By integrating with New Relic, you can send your SendGrid email statistics to yo
```php
$request_body = json_decode('{
- "enable_subuser_statistics": true,
- "enabled": true,
+ "enable_subuser_statistics": true,
+ "enabled": true,
"license_key": ""
}');
$response = $sg->client->partner_settings()->new_relic()->patch($request_body);
@@ -2569,7 +2570,7 @@ echo $response->headers();
**This endpoint returns a list of all scopes that this user has access to.**
-API Keys can be used to authenticate the use of [SendGrids v3 Web API](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html), or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). API Keys may be assigned certain permissions, or scopes, that limit which API endpoints they are able to access. For a more detailed explanation of how you can use API Key permissios, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/api_keys.html#-API-Key-Permissions) or [Classroom](https://sendgrid.com/docs/Classroom/Basics/API/api_key_permissions.html).
+API Keys can be used to authenticate the use of [SendGrids v3 Web API](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html), or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). API Keys may be assigned certain permissions, or scopes, that limit which API endpoints they are able to access. For a more detailed explanation of how you can use API Key permissios, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/api_keys.html#-API-Key-Permissions) or [Classroom](https://sendgrid.com/docs/Classroom/Basics/API/api_key_permissions.html).
### GET /scopes
@@ -2616,12 +2617,12 @@ For more information about Subusers:
```php
$request_body = json_decode('{
- "email": "John@example.com",
+ "email": "John@example.com",
"ips": [
- "1.1.1.1",
+ "1.1.1.1",
"2.2.2.2"
- ],
- "password": "johns_password",
+ ],
+ "password": "johns_password",
"username": "John@example.com"
}');
$response = $sg->client->subusers()->post($request_body);
@@ -2767,7 +2768,7 @@ echo $response->headers();
```
## Update IPs assigned to a subuser
-Each subuser should be assigned to an IP address, from which all of this subuser's mail will be sent. Often, this is the same IP as the parent account, but each subuser can have their own, or multiple, IP addresses as well.
+Each subuser should be assigned to an IP address, from which all of this subuser's mail will be sent. Often, this is the same IP as the parent account, but each subuser can have their own, or multiple, IP addresses as well.
More information:
@@ -2796,7 +2797,7 @@ Subuser monitor settings allow you to receive a sample of an outgoing message by
```php
$request_body = json_decode('{
- "email": "example@example.com",
+ "email": "example@example.com",
"frequency": 500
}');
$subuser_name = "test_url_param";
@@ -2814,7 +2815,7 @@ Subuser monitor settings allow you to receive a sample of an outgoing message by
```php
$request_body = json_decode('{
- "email": "example@example.com",
+ "email": "example@example.com",
"frequency": 50000
}');
$subuser_name = "test_url_param";
@@ -2898,9 +2899,9 @@ echo $response->headers();
**This endpoint allows you to delete all email addresses on your blocks list.**
-There are two options for deleting blocked emails:
+There are two options for deleting blocked emails:
-1. You can delete all blocked emails by setting `delete_all` to true in the request body.
+1. You can delete all blocked emails by setting `delete_all` to true in the request body.
2. You can delete some blocked emails by specifying the email addresses in an array in the request body.
[Blocks](https://sendgrid.com/docs/Glossary/blocks.html) happen when your message was rejected for a reason related to the message, not the recipient address. This can happen when your mail server IP address has been added to a blacklist or blocked by an ISP, or if the message content is flagged by a filter on the receiving server.
@@ -2912,9 +2913,9 @@ For more information, please see our [User Guide](https://sendgrid.com/docs/User
```php
$request_body = json_decode('{
- "delete_all": false,
+ "delete_all": false,
"emails": [
- "example1@example.com",
+ "example1@example.com",
"example2@example.com"
]
}');
@@ -2963,9 +2964,9 @@ echo $response->headers();
**This endpoint allows you to retrieve all of your bounces.**
-Bounces are messages that are returned to the server that sent it.
+Bounces are messages that are returned to the server that sent it.
-For more information see:
+For more information see:
* [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information
* [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html)
@@ -2986,7 +2987,7 @@ echo $response->headers();
Bounces are messages that are returned to the server that sent it.
-For more information see:
+For more information see:
* [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information
* [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html)
@@ -2999,9 +3000,9 @@ Note: the `delete_all` and `emails` parameters should be used independently of e
```php
$request_body = json_decode('{
- "delete_all": true,
+ "delete_all": true,
"emails": [
- "example@example.com",
+ "example@example.com",
"example2@example.com"
]
}');
@@ -3016,7 +3017,7 @@ echo $response->headers();
Bounces are messages that are returned to the server that sent it.
-For more information see:
+For more information see:
* [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information
* [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html)
@@ -3036,9 +3037,9 @@ echo $response->headers();
**This endpoint allows you to remove an email address from your bounce list.**
-Bounces are messages that are returned to the server that sent it. This endpoint allows you to delete a single email addresses from your bounce list.
+Bounces are messages that are returned to the server that sent it. This endpoint allows you to delete a single email addresses from your bounce list.
-For more information see:
+For more information see:
* [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information
* [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html)
@@ -3079,7 +3080,7 @@ echo $response->headers();
**This endpoint allows you to remove email addresses from your invalid email address list.**
-There are two options for deleting invalid email addresses:
+There are two options for deleting invalid email addresses:
1) You can delete all invalid email addresses by setting `delete_all` to true in the request body.
2) You can delete some invalid email addresses by specifying certain addresses in an array in the request body.
@@ -3095,9 +3096,9 @@ For more information, please see our [User Guide](https://sendgrid.com/docs/User
```php
$request_body = json_decode('{
- "delete_all": false,
+ "delete_all": false,
"emails": [
- "example1@example.com",
+ "example1@example.com",
"example2@example.com"
]
}');
@@ -3204,9 +3205,9 @@ echo $response->headers();
**This endpoint allows you to delete your spam reports.**
-There are two options for deleting spam reports:
+There are two options for deleting spam reports:
-1) You can delete all spam reports by setting "delete_all" to true in the request body.
+1) You can delete all spam reports by setting "delete_all" to true in the request body.
2) You can delete some spam reports by specifying the email addresses in an array in the request body.
[Spam reports](https://sendgrid.com/docs/Glossary/spam_reports.html) happen when a recipient indicates that they think your email is [spam](https://sendgrid.com/docs/Glossary/spam.html) and then their email provider reports this to SendGrid.
@@ -3218,9 +3219,9 @@ For more information, please see our [User Guide](https://sendgrid.com/docs/User
```php
$request_body = json_decode('{
- "delete_all": false,
+ "delete_all": false,
"emails": [
- "example1@example.com",
+ "example1@example.com",
"example2@example.com"
]
}');
@@ -3359,11 +3360,11 @@ For more information about transactional templates, please see our [User Guide](
```php
$request_body = json_decode('{
- "active": 1,
- "html_content": "<%body%>",
- "name": "example_version_name",
- "plain_content": "<%body%>",
- "subject": "<%subject%>",
+ "active": 1,
+ "html_content": "<%body%>",
+ "name": "example_version_name",
+ "plain_content": "<%body%>",
+ "subject": "<%subject%>",
"template_id": "ddb96bbc-9b92-425e-8979-99464621b543"
}');
$template_id = "test_url_param";
@@ -3391,10 +3392,10 @@ For more information about transactional templates, please see our [User Guide](
```php
$request_body = json_decode('{
- "active": 1,
- "html_content": "<%body%>",
- "name": "updated_example_name",
- "plain_content": "<%body%>",
+ "active": 1,
+ "html_content": "<%body%>",
+ "name": "updated_example_name",
+ "plain_content": "<%body%>",
"subject": "<%subject%>"
}');
$template_id = "test_url_param";
@@ -3555,11 +3556,11 @@ For more information about tracking, please see our [User Guide](https://sendgri
```php
$request_body = json_decode('{
- "enabled": true,
- "utm_campaign": "website",
- "utm_content": "",
- "utm_medium": "email",
- "utm_source": "sendgrid.com",
+ "enabled": true,
+ "utm_campaign": "website",
+ "utm_content": "",
+ "utm_medium": "email",
+ "utm_source": "sendgrid.com",
"utm_term": ""
}');
$response = $sg->client->tracking_settings()->google_analytics()->patch($request_body);
@@ -3644,11 +3645,11 @@ For more information about tracking, please see our [User Guide](https://sendgri
```php
$request_body = json_decode('{
- "enabled": true,
- "html_content": "html content",
- "landing": "landing page html",
- "plain_content": "text content",
- "replace": "replacement tag",
+ "enabled": true,
+ "html_content": "html content",
+ "landing": "landing page html",
+ "plain_content": "text content",
+ "replace": "replacement tag",
"url": "url"
}');
$response = $sg->client->tracking_settings()->subscription()->patch($request_body);
@@ -3770,7 +3771,7 @@ For more information about your user profile:
```php
$request_body = json_decode('{
- "new_password": "new_password",
+ "new_password": "new_password",
"old_password": "old_password"
}');
$response = $sg->client->user()->password()->put($request_body);
@@ -3795,8 +3796,8 @@ It should be noted that any one or more of the parameters can be updated via the
```php
$request_body = json_decode('{
- "city": "Orange",
- "first_name": "Example",
+ "city": "Orange",
+ "first_name": "Example",
"last_name": "User"
}');
$response = $sg->client->user()->profile()->patch($request_body);
@@ -3835,7 +3836,7 @@ The Cancel Scheduled Sends feature allows the customer to cancel a scheduled sen
```php
$request_body = json_decode('{
- "batch_id": "YOUR_BATCH_ID",
+ "batch_id": "YOUR_BATCH_ID",
"status": "pause"
}');
$response = $sg->client->user()->scheduled_sends()->post($request_body);
@@ -3922,7 +3923,7 @@ The Enforced TLS settings specify whether or not the recipient is required to su
```php
$request_body = json_decode('{
- "require_tls": true,
+ "require_tls": true,
"require_valid_cert": false
}');
$response = $sg->client->user()->settings()->enforced_tls()->patch($request_body);
@@ -4003,18 +4004,18 @@ Common uses of this data are to remove unsubscribes, react to spam reports, dete
```php
$request_body = json_decode('{
- "bounce": true,
- "click": true,
- "deferred": true,
- "delivered": true,
- "dropped": true,
- "enabled": true,
- "group_resubscribe": true,
- "group_unsubscribe": true,
- "open": true,
- "processed": true,
- "spam_report": true,
- "unsubscribe": true,
+ "bounce": true,
+ "click": true,
+ "deferred": true,
+ "delivered": true,
+ "dropped": true,
+ "enabled": true,
+ "group_resubscribe": true,
+ "group_unsubscribe": true,
+ "open": true,
+ "processed": true,
+ "spam_report": true,
+ "unsubscribe": true,
"url": "url"
}');
$response = $sg->client->user()->webhooks()->event()->settings()->patch($request_body);
@@ -4041,7 +4042,7 @@ echo $response->statusCode();
echo $response->body();
echo $response->headers();
```
-## Test Event Notification Settings
+## Test Event Notification Settings
**This endpoint allows you to test your event webhook by sending a fake event notification post to the provided URL.**
@@ -4114,15 +4115,15 @@ For more information on whitelabeling, please see our [User Guide](https://sendg
```php
$request_body = json_decode('{
- "automatic_security": false,
- "custom_spf": true,
- "default": true,
- "domain": "example.com",
+ "automatic_security": false,
+ "custom_spf": true,
+ "default": true,
+ "domain": "example.com",
"ips": [
- "192.168.1.1",
+ "192.168.1.1",
"192.168.1.2"
- ],
- "subdomain": "news",
+ ],
+ "subdomain": "news",
"username": "john@example.com"
}');
$response = $sg->client->whitelabel()->domains()->post($request_body);
@@ -4232,7 +4233,7 @@ For more information on whitelabeling, please see our [User Guide](https://sendg
```php
$request_body = json_decode('{
- "custom_spf": true,
+ "custom_spf": true,
"default": false
}');
$domain_id = "test_url_param";
@@ -4395,8 +4396,8 @@ For more information, please see our [User Guide](https://sendgrid.com/docs/API_
```php
$request_body = json_decode('{
- "domain": "example.com",
- "ip": "192.168.1.1",
+ "domain": "example.com",
+ "ip": "192.168.1.1",
"subdomain": "email"
}');
$response = $sg->client->whitelabel()->ips()->post($request_body);
@@ -4491,8 +4492,8 @@ For more information, please see our [User Guide](https://sendgrid.com/docs/API_
```php
$request_body = json_decode('{
- "default": true,
- "domain": "example.com",
+ "default": true,
+ "domain": "example.com",
"subdomain": "mail"
}');
$query_params = json_decode('{"limit": 1, "offset": 1}');
diff --git a/examples/mail/mail.php b/examples/mail/mail.php
index b467b10..be64198 100644
--- a/examples/mail/mail.php
+++ b/examples/mail/mail.php
@@ -26,153 +26,154 @@ echo $response->body();
echo $response->headers();
////////////////////////////////////////////////////
-// v3 Mail Send Beta #
-// POST /mail/send/beta #
+// v3 Mail Send #
+// POST /mail/send #
+// This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-php/blob/master/lib/helpers/mail/README.md).
$request_body = json_decode('{
"asm": {
- "group_id": 1,
+ "group_id": 1,
"groups_to_display": [
- 1,
- 2,
+ 1,
+ 2,
3
]
- },
+ },
"attachments": [
{
- "content": "[BASE64 encoded content block here]",
- "content_id": "ii_139db99fdb5c3704",
- "disposition": "inline",
- "filename": "file1.jpg",
- "name": "file1",
+ "content": "[BASE64 encoded content block here]",
+ "content_id": "ii_139db99fdb5c3704",
+ "disposition": "inline",
+ "filename": "file1.jpg",
+ "name": "file1",
"type": "jpg"
}
- ],
- "batch_id": "[YOUR BATCH ID GOES HERE]",
+ ],
+ "batch_id": "[YOUR BATCH ID GOES HERE]",
"categories": [
- "category1",
+ "category1",
"category2"
- ],
+ ],
"content": [
{
- "type": "text/html",
+ "type": "text/html",
"value": "<html><p>Hello, world!</p><img src=[CID GOES HERE]></img></html>"
}
- ],
+ ],
"custom_args": {
- "New Argument 1": "New Value 1",
- "activationAttempt": "1",
+ "New Argument 1": "New Value 1",
+ "activationAttempt": "1",
"customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
- },
+ },
"from": {
- "email": "sam.smith@example.com",
+ "email": "sam.smith@example.com",
"name": "Sam Smith"
- },
- "headers": {},
- "ip_pool_name": "[YOUR POOL NAME GOES HERE]",
+ },
+ "headers": {},
+ "ip_pool_name": "[YOUR POOL NAME GOES HERE]",
"mail_settings": {
"bcc": {
- "email": "ben.doe@example.com",
+ "email": "ben.doe@example.com",
"enable": true
- },
+ },
"bypass_list_management": {
"enable": true
- },
+ },
"footer": {
- "enable": true,
- "html": "<p>Thanks</br>The SendGrid Team</p>",
+ "enable": true,
+ "html": "<p>Thanks</br>The SendGrid Team</p>",
"text": "Thanks,/n The SendGrid Team"
- },
+ },
"sandbox_mode": {
"enable": false
- },
+ },
"spam_check": {
- "enable": true,
- "post_to_url": "http://example.com/compliance",
+ "enable": true,
+ "post_to_url": "http://example.com/compliance",
"threshold": 3
}
- },
+ },
"personalizations": [
{
"bcc": [
{
- "email": "sam.doe@example.com",
+ "email": "sam.doe@example.com",
"name": "Sam Doe"
}
- ],
+ ],
"cc": [
{
- "email": "jane.doe@example.com",
+ "email": "jane.doe@example.com",
"name": "Jane Doe"
}
- ],
+ ],
"custom_args": {
- "New Argument 1": "New Value 1",
- "activationAttempt": "1",
+ "New Argument 1": "New Value 1",
+ "activationAttempt": "1",
"customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
- },
+ },
"headers": {
- "X-Accept-Language": "en",
+ "X-Accept-Language": "en",
"X-Mailer": "MyApp"
- },
- "send_at": 1409348513,
- "subject": "Hello, World!",
+ },
+ "send_at": 1409348513,
+ "subject": "Hello, World!",
"substitutions": {
"sub": {
"%name%": [
- "John",
- "Jane",
+ "John",
+ "Jane",
"Sam"
]
}
- },
+ },
"to": [
{
- "email": "john.doe@example.com",
+ "email": "john.doe@example.com",
"name": "John Doe"
}
]
}
- ],
+ ],
"reply_to": {
- "email": "sam.smith@example.com",
+ "email": "sam.smith@example.com",
"name": "Sam Smith"
- },
+ },
"sections": {
"section": {
- ":sectionName1": "section 1 text",
+ ":sectionName1": "section 1 text",
":sectionName2": "section 2 text"
}
- },
- "send_at": 1409348513,
- "subject": "Hello, World!",
- "template_id": "[YOUR TEMPLATE ID GOES HERE]",
+ },
+ "send_at": 1409348513,
+ "subject": "Hello, World!",
+ "template_id": "[YOUR TEMPLATE ID GOES HERE]",
"tracking_settings": {
"click_tracking": {
- "enable": true,
+ "enable": true,
"enable_text": true
- },
+ },
"ganalytics": {
- "enable": true,
- "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]",
- "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]",
- "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]",
- "utm_name": "[NAME OF YOUR CAMPAIGN]",
+ "enable": true,
+ "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]",
+ "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]",
+ "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]",
+ "utm_name": "[NAME OF YOUR CAMPAIGN]",
"utm_term": "[IDENTIFY PAID KEYWORDS HERE]"
- },
+ },
"open_tracking": {
- "enable": true,
+ "enable": true,
"substitution_tag": "%opentrack"
- },
+ },
"subscription_tracking": {
- "enable": true,
- "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
- "substitution_tag": "<%click here%>",
+ "enable": true,
+ "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
+ "substitution_tag": "<%click here%>",
"text": "If you would like to unsubscribe and stop receiveing these emails <% click here %>."
}
}
}');
-$response = $sg->client->mail()->send()->beta()->post($request_body);
+$response = $sg->client->mail()->send()->post($request_body);
echo $response->statusCode();
echo $response->body();
echo $response->headers();