Built-in Multiple Images Mailgun API Batch

I am trying to transfer multiple images through the built-in Mailgun API. I have no problem with just one image, but when I try to use multiple images - as in the code below, the message displays only the last image in the array.

$template = View::make('emails.template')->render(); $result = $mgClient->sendMessage($domain, array( 'from' => $sender, 'to' => implode(',',$emailAddresses), 'subject' => '%recipient.subject%', 'text' => $messageText, 'recipient-variables' => json_encode($credentials), 'html' => $template ), array( 'inline' => array( 'path/to/image1.png', 'path/to/image2.png', 'path/to/image3.png', 'path/to/image4.png') )); 

The above code works as if the last element in the array is the only element.

The documentation for sending inline images with Mailgun is here , and she said here that โ€œyou can post multiple inline values,โ€ which means that I'm definitely doing something wrong.

+5
source share
2 answers

This was a recently introduced error. A new feed request was sent to the official Mailgun PHP SDK, for more information see here .

So, to answer the question: the code works fine as soon as the SDK is updated according to the above download request. At the moment, I edited my local copy of mailgun-php accordingly, and it worked fine. Many thanks to Travis Sventek at Mailgun for the quick reply.

+2
source

Try once:

 $result = $mgClient->sendMessage($domain, array( 'from' => $sender, 'to' => implode(',',$emailAddresses), 'subject' => '%recipient.subject%', 'text' => $messageText, 'recipient-variables' => json_encode($credentials), 'html' => $template ), array( 'inline' => array( array('path/to/image1.png'), array('path/to/image2.png'), array('path/to/image3.png'), array('path/to/image4.png') ))); 

Basically a wrapper for each image path in an array.

And what is the contents of $template ?

+2
source

All Articles