From c7c345d1c262a20f655ca94f1641b8f83b9a0e45 Mon Sep 17 00:00:00 2001 From: Michael <24801204+michaelhyattdev@users.noreply.github.com> Date: Sun, 30 Jan 2022 12:15:48 -0600 Subject: [PATCH] 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. --- src/Message/README.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Message/README.md b/src/Message/README.md index 8573104..c722544 100644 --- a/src/Message/README.md +++ b/src/Message/README.md @@ -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("
This is the HTML body of the message
"); -$builder->setTemplate("template_name"); +$batchMessage->setTextBody("This is the text body of the message!"); +$batchMessage->setHtmlBody("This is the HTML body of the message
"); +$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"));