PHP code example of pepipost / pepipost-sdk-php

1. Go to this page and download the library: Download pepipost/pepipost-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pepipost / pepipost-sdk-php example snippets

 -v



pipostLib\Models;
use PepipostLib\Exceptions;

$apiKey = '96c909c62bcc1dfdacef7dfdda34ea8477';

$client = new PepipostLib\PepipostClient($apiKey);
$sendController = $client->getMailSend();

$body = new Models\Send;
$body->from = new Models\From;
$body->from->email = 'hello@your-registered-domain-with-pepipost';
$body->from->name = 'Pepipost';
$body->subject = 'Pepipost Test Mail from PHP SDK';


$body->content = array();
$body->content[0] = new Models\Content;
$body->content[0]->type = Models\TypeEnum::HTML;
$body->content[0]->value = '<html><body>Hello [%NAME%], Email testing is successful. <br> Hope you enjoyed this integration. <br></html>';

$body->personalizations = array();
$body->personalizations[0] = new Models\Personalizations;
$body->personalizations[0]->attributes = PepipostLib\APIHelper::deserialize('{"NAME":"User"}');
$body->personalizations[0]->to = array();

$body->personalizations[0]->to[0] = new Models\EmailStruct;
$body->personalizations[0]->to[0]->name = '[email protected]';
$body->personalizations[0]->to[0]->email = 'my-first-user';

$body->settings = new Models\Settings;
$body->settings->footer = true;
$body->settings->clickTrack = true;
$body->settings->openTrack = true;
$body->settings->unsubscribeTrack = true;

try {
  $result = $sendController->createGenerateTheMailSendRequest($body);
  var_dump($result);
} catch (PepipostLib\APIException $e) {
    echo 'Caught APIException: ',  $e->getMessage(), "\n"; 
}
 test.php
git clone https://github.com/pepipost/pepipost-sdk-php.git testSDK
cp simple-usage.md test.php
$apiKey = 'api-XX-key-XX-here'