Skip to content

pvwalke/pepipost-sdk-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pepipost API SDK-PHP

This Pepipost API SDK-PHP.

It was semi-auto generated by APIMATIC v2.0. Thanks to APIMATIC

INSTALLATION

Installing via Composer

Using Composer is the recommended way to install the Pepipost SDK for PHP. Composer is a dependency management tool for PHP that allows you to declare the dependencies your project needs and installs them into your project.

Install Composer

curl -sS https://getcomposer.org/installer | php

Run Composer

php composer.phar require pepipost/pepipost-sdk-php:v1.0.0

USAGE

<?php

require_once __DIR__.'/vendor/autoload.php';

use PepipostAPIV10Lib\Controllers\Email;

$email = new Email();

$data = array(
    'api_key'        =>  'yoursecretapikey',
    'recipients'    =>  array('[email protected]'),
    'email_details' => array(
        'content'       =>  'this mail is sent via PHP SDK',
        'from'          =>  '[email protected]',
        'subject'       =>  'this mail is sent via PHP SDK',
        'fromname'      =>  'SDK Sender Name ',    
    )
);

try {
    $response = $email->sendJson( $data );
    if(empty($response->errorcode)){
        print "Email sent successfully.\n";
    }
    else {
        print "Email sent Failed.\n";
        print "errormessage(" . $response->errormessage . ") \n";
        print "errorcode(" . $response->errorcode . ").\n";
    }
}
catch(Exception $e){
    print 'Call failed due to unhandled exception/error('. $e->getMessage().')'."\n";
}

Advance Usage Example

<?php

require_once __DIR__.'/vendor/autoload.php';

use PepipostAPIV10Lib\Controllers\Email;

$email = new Email();

$data = array(
    'api_key'   =>  'yoursecretkey',
    'recipients'    =>  array('[email protected]','[email protected]'),
    'email_details' => array(
        'from'          =>  '[email protected]',
        'subject'       =>  'Hi [% NAME %], here is your account balance.',
        'content'       =>  '<p>Hi [%NAME%],</p><p>Your account balance is [% ACCOUNT_BAL %].</p>',
        'fromname'      =>  'SDK Sender Name ',
        'replytoid'     =>  '[email protected]',
    ),
    'tags'          =>  'AccountDeactivation, Verification',
    'X-APIHEADER' => array('UserID1','UserID2'),
    'settings' => array(
        'footer'        =>  true,
        'clicktrack'    =>  true,
        'opentrack'     =>  true,
        'unsubscribe'   =>  true,
        'bcc'           =>  '[email protected]',
    ),
    'attributes' => array(
        'NAME'          => array('NameOfRecipient1','NameOfRecipient2'),
        'ACCOUNT_BAL'   => array('100','200'),
    ),    
    'files' => array(
        'example_attachment1.txt' => base64_encode(trim(file_get_contents('/path/to/file.txt'))),
        'example_attachment2.pdf' => base64_encode(trim(file_get_contents('/path/to/file.pdf'))),
    ),  
);

try {
    $response = $email->sendJson( $data );
    //var_dump($response);
    if(empty($response->errorcode)){
        print "Email sent successfully.\n";
    }
    else {
        print "Email sent Failed.\n";
        print "errormessage(" . $response->errormessage . ") \n";
        print "errorcode(" . $response->errorcode . ").\n";
    }
}
catch(Exception $e){
    print 'Call failed due to unhandled exception/error('. $e->getMessage().')'."\n";
}

Response format

    $response-> message = "SUCCESS";
    $response-> errorcode = 0;
    $response-> errormessage = '';

About

Official repository of the Pepipost SDK for PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%