mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-22 04:26:02 +03:00
Updated README
This commit is contained in:
parent
52808cc565
commit
89a2e8bd09
56
README.md
56
README.md
@ -2,16 +2,20 @@ Mailgun-PHP
|
||||
===========
|
||||
[![Build Status](https://travis-ci.org/travelton/Mailgun-PHP.png?branch=master)](https://travis-ci.org/travelton/Mailgun-PHP)
|
||||
|
||||
This is the Mailgun PHP SDK. This SDK contains methods for easily interacting with the Mailgun API.
|
||||
Below are examples to get you started. For additional examples, please see our official documentation
|
||||
This is the Mailgun PHP SDK. This SDK contains methods for easily interacting
|
||||
with the Mailgun API.
|
||||
Below are examples to get you started. For additional examples, please see our
|
||||
official documentation
|
||||
at http://documentation.mailgun.com
|
||||
|
||||
Current Release: 0.7
|
||||
|
||||
Installation
|
||||
------------
|
||||
To install the SDK, you will need to be using [Composer](http://getcomposer.org/) in your project.
|
||||
If you aren't using Composer yet, it's really simple! Here's how to install composer and the Mailgun SDK.
|
||||
To install the SDK, you will need to be using [Composer](http://getcomposer.org/)
|
||||
in your project.
|
||||
If you aren't using Composer yet, it's really simple! Here's how to install
|
||||
composer and the Mailgun SDK.
|
||||
|
||||
```PHP
|
||||
# Install Composer
|
||||
@ -21,12 +25,14 @@ curl -sS https://getcomposer.org/installer | php
|
||||
php composer.phar require mailgun/mailgun-php:~0.7
|
||||
```
|
||||
|
||||
For shared hosts with SSH access, you might need to run this instead (contact your shared host for assistance):
|
||||
For shared hosts with SSH access, you might need to run this instead (contact
|
||||
your shared host for assistance):
|
||||
```
|
||||
php -d detect_unicode=Off -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
|
||||
```
|
||||
|
||||
Next, require Composer's autoloader, in your application, to automatically load the Mailgun SDK in your project:
|
||||
Next, require Composer's autoloader, in your application, to automatically
|
||||
load the Mailgun SDK in your project:
|
||||
```PHP
|
||||
require 'vendor/autoload.php';
|
||||
use Mailgun\Mailgun;
|
||||
@ -62,7 +68,8 @@ $mg->get("$domain/log", array('limit' => 25,
|
||||
Result
|
||||
------
|
||||
|
||||
The results, provided by the endpoint, are returned as an object, which you can traverse like an array.
|
||||
The results, provided by the endpoint, are returned as an object, which you
|
||||
can traverse like an array.
|
||||
|
||||
Example:
|
||||
|
||||
@ -71,16 +78,19 @@ $mg = new Mailgun("key-example");
|
||||
$domain = "example.com";
|
||||
|
||||
$result = $mg->get("$domain/log", array('limit' => 25,
|
||||
'skip' => 0);
|
||||
'skip' => 0);
|
||||
|
||||
$httpResponseCode = $result->http_response_code;
|
||||
$httpResponseBody = $result->http_response_body;
|
||||
```
|
||||
|
||||
Example Contents:
|
||||
$httpResponseCode will contain an integer. You can find how we use HTTP response codes in our documentation: http://documentation.mailgun.com/api-intro.html?highlight=401#errors
|
||||
**$httpResponseCode** will contain an integer. You can find how we use HTTP response
|
||||
codes in our documentation:
|
||||
http://documentation.mailgun.com/api-intro.html?highlight=401#errors
|
||||
|
||||
$httpResponseBody will contain an object of the API response. In the above example, a var_dump($result) would contain the following:
|
||||
**$httpResponseBody** will contain an object of the API response. In the above
|
||||
example, a var_dump($result) would contain the following:
|
||||
|
||||
```
|
||||
["http_response_body"]=>
|
||||
@ -96,7 +106,9 @@ $httpResponseBody will contain an object of the API response. In the above examp
|
||||
["created_at"]=>
|
||||
string(29) "Mon, 19 Aug 2013 19:41:33 GMT"
|
||||
["message"]=>
|
||||
string(155) "Will retry in 14400 seconds: me@samples.mailgun.org → sergeyo@profista.com 'Hello' No MX for [profista.com] Server response: 498 No MX for [profista.com]"
|
||||
string(155) "Will retry in 14400 seconds: me@samples.mailgun.org →
|
||||
sergeyo@profista.com 'Hello' No MX for [profista.com] Server response:
|
||||
498 No MX for [profista.com]"
|
||||
["type"]=>
|
||||
string(4) "warn"
|
||||
["message_id"]=>
|
||||
@ -106,19 +118,27 @@ $httpResponseBody will contain an object of the API response. In the above examp
|
||||
}
|
||||
```
|
||||
|
||||
For usage examples on each API endpoint, head over to our official documentation pages.
|
||||
For usage examples on each API endpoint, head over to our official documentation
|
||||
pages.
|
||||
|
||||
This SDK includes a [Message Builder](src/Mailgun/Messages/README.md) and [Batch Message](src/Mailgun/Messages/README.md) component.
|
||||
This SDK includes a [Message Builder](src/Mailgun/Messages/README.md) and
|
||||
[Batch Message](src/Mailgun/Messages/README.md) component.
|
||||
|
||||
Message Builder allows you to quickly create the array of parameters, required to send a message, by calling a methods for each parameter.
|
||||
Batch Message is an extension of Message Builder, and allows you to easily send a batch message job within a few seconds. The complexity of
|
||||
Message Builder allows you to quickly create the array of parameters, required
|
||||
to send a message, by calling a methods for each parameter.
|
||||
Batch Message is an extension of Message Builder, and allows you to easily send
|
||||
a batch message job within a few seconds. The complexity of
|
||||
batch messaging is eliminated!
|
||||
|
||||
Support and Feedback
|
||||
--------------------
|
||||
|
||||
Be sure to visit the Mailgun official [documentation website](http://documentation.mailgun.com/) for additional information about our API.
|
||||
Be sure to visit the Mailgun official
|
||||
[documentation website](http://documentation.mailgun.com/) for additional
|
||||
information about our API.
|
||||
|
||||
If you find a bug, please submit the issue in Github directly. [Mailgun-PHP Issues](https://github.com/mailgun/Mailgun-PHP/issues)
|
||||
If you find a bug, please submit the issue in Github directly.
|
||||
[Mailgun-PHP Issues](https://github.com/mailgun/Mailgun-PHP/issues)
|
||||
|
||||
As always, if you need additional assistance, drop us a note at [support@mailgun.com](mailto:support@mailgun.com).
|
||||
As always, if you need additional assistance, drop us a note at
|
||||
[support@mailgun.com](mailto:support@mailgun.com).
|
||||
|
@ -3,7 +3,8 @@ Mailgun - Lists
|
||||
|
||||
This is the Mailgun PHP *Lists* utilities.
|
||||
|
||||
The below assumes you've already installed the Mailgun PHP SDK in to your project. If not, go back to the master README for instructions.
|
||||
The below assumes you've already installed the Mailgun PHP SDK in to your project.
|
||||
If not, go back to the master README for instructions.
|
||||
|
||||
There is currently one utility provided.
|
||||
|
||||
@ -93,10 +94,14 @@ if($hashValidation){
|
||||
```
|
||||
|
||||
A few notes:
|
||||
1. 'a_secret_passphrase' can be anything. It's used as the *key* in hashing, since your email address will vary.
|
||||
2. validateHash() will return an array containing the recipient address and list address.
|
||||
3. You should *always* send an email confirmation before and after the subscription request.
|
||||
4. WARNING: On $_GET['hash'], you need to sanitize this value to prevent malicious attempts to inject code.
|
||||
1. 'a_secret_passphrase' can be anything. It's used as the *key* in hashing,
|
||||
since your email address will vary.
|
||||
2. validateHash() will return an array containing the recipient address and list
|
||||
address.
|
||||
3. You should *always* send an email confirmation before and after the
|
||||
subscription request.
|
||||
4. WARNING: On $_GET['hash'], you need to sanitize this value to prevent
|
||||
malicious attempts to inject code.
|
||||
|
||||
Available Functions
|
||||
-----------------------------------------------------
|
||||
@ -107,4 +112,5 @@ Available Functions
|
||||
|
||||
More Documentation
|
||||
------------------
|
||||
See the official [Mailgun Docs](http://documentation.mailgun.com/api-sending.html) for more information.
|
||||
See the official [Mailgun Docs](http://documentation.mailgun.com/api-sending.html)
|
||||
for more information.
|
||||
|
@ -3,12 +3,16 @@ Mailgun - Messages
|
||||
|
||||
This is the Mailgun PHP *Message* utilities.
|
||||
|
||||
The below assumes you've already installed the Mailgun PHP SDK in to your project. If not, go back to the master README for instructions.
|
||||
The below assumes you've already installed the Mailgun PHP SDK in to your
|
||||
project. If not, go back to the master README for instructions.
|
||||
|
||||
There are two utilities included, Message Builder and Batch Message.
|
||||
|
||||
Message Builder: Allows you to build a message object by calling methods for each MIME attribute.
|
||||
Batch Message: Inherits Message Builder and allows you to iterate through recipients from a list. Messages will fire after the 1,000th recipient has been added.
|
||||
Message Builder: Allows you to build a message object by calling methods for
|
||||
each MIME attribute.
|
||||
Batch Message: Inherits Message Builder and allows you to iterate through
|
||||
recipients from a list. Messages will fire after the 1,000th recipient has been
|
||||
added.
|
||||
|
||||
Usage - Message Builder
|
||||
-----------------------
|
||||
@ -95,7 +99,8 @@ Here's how to use Batch Message to easily handle batch sending jobs.
|
||||
$mg = new Mailgun("key-example");
|
||||
$domain = "example.com";
|
||||
|
||||
# Next, instantiate a Message Builder object from the SDK, pass in your sending domain.
|
||||
# Next, instantiate a Message Builder object from the SDK, pass in your sending
|
||||
domain.
|
||||
$batchMsg = $mg->BatchMessage($domain);
|
||||
|
||||
# Define the from address.
|
||||
@ -110,7 +115,8 @@ $batchMsg->addToRecipient("john.doe@samples.mailgun.org", array("first" => "John
|
||||
$batchMsg->addToRecipient("sally.doe@samples.mailgun.org", array("first" => "Sally", "last" => "Doe"));
|
||||
$batchMsg->addToRecipient("mike.jones@samples.mailgun.org", array("first" => "Mike", "last" => "Jones"));
|
||||
...
|
||||
// After 1,000 recipeints, Batch Message will automatically post your message to the messages endpoint.
|
||||
// After 1,000 recipeints, Batch Message will automatically post your message to
|
||||
the messages endpoint.
|
||||
|
||||
// Call finalize() to send any remaining recipients still in the buffer.
|
||||
$batchMsg->finalize();
|
||||
@ -128,4 +134,5 @@ Available Functions (Inherits all Batch Message and Messages Functions)
|
||||
|
||||
More Documentation
|
||||
------------------
|
||||
See the official [Mailgun Docs](http://documentation.mailgun.com/api-sending.html) for more information.
|
||||
See the official [Mailgun Docs](http://documentation.mailgun.com/api-sending.html)
|
||||
for more information.
|
||||
|
Loading…
Reference in New Issue
Block a user