Update Message Builder Documentation

Fixed typos in the Batch Message example. Added dependency requirement in the Message Builder example. Reorganized the Message Builder example for uniformity.
This commit is contained in:
Michael 2022-01-30 12:15:48 -06:00 committed by David Garcia
parent 1972acadfa
commit c7c345d1c2

View File

@ -19,6 +19,13 @@ Usage - Message Builder
Here's how to use Message Builder to build your Message.
```php
require 'vendor/autoload.php';
use Mailgun\Mailgun;
use Mailgun\Message\MessageBuilder;
// First, instantiate the SDK with your API credentials
$mg = Mailgun::create('key-example');
# Next, instantiate a Message Builder object from the SDK.
$builder = new MessageBuilder();
@ -43,8 +50,6 @@ $builder->setDeliveryTime("tomorrow 8:00AM", "PST");
$builder->setClickTracking(true);
# Finally, send the message.
$mg = Mailgun::create('key-example');
$domain = ;
$mg->messages()->send("example.com", $builder->getMessage());
```
@ -53,8 +58,11 @@ Usage - Batch Message
Here's how to use Batch Message to easily handle batch sending jobs.
```php
# First, instantiate the SDK with your API credentials and define your domain.
$mg = new Mailgun("key-example");
require 'vendor/autoload.php';
use Mailgun\Mailgun;
// First, instantiate the SDK with your API credentials
$mg = Mailgun::create('key-example');
# Next, instantiate a Message Builder object from the SDK, pass in your sending domain.
$batchMessage = $mg->messages()->getBatchMessage("example.com");
@ -64,9 +72,9 @@ $batchMessage->setFromAddress("me@example.com", array("first"=>"PHP", "last" =>
# Define the subject.
$batchMessage->setSubject("A Batch Message from the PHP SDK!");
# Define the body of the message (One is required).
$builder->setTextBody("This is the text body of the message!");
$builder->setHtmlBody("<html><p>This is the HTML body of the message</p></html>");
$builder->setTemplate("template_name");
$batchMessage->setTextBody("This is the text body of the message!");
$batchMessage->setHtmlBody("<html><p>This is the HTML body of the message</p></html>");
$batchMessage->setTemplate("template_name");
# Next, let's add a few recipients to the batch job.
$batchMessage->addToRecipient("john.doe@example.com", array("first" => "John", "last" => "Doe"));