PHP code example of arseniusz8 / sendpost_php

1. Go to this page and download the library: Download arseniusz8/sendpost_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/ */

    

arseniusz8 / sendpost_php example snippets




    
       new GuzzleHttp\Client();

      $apiInstance = new sendpost\api\EmailApi($client);
  
      $x_sub_account_api_key = 'your_api_key'; // string | Sub-Account API Key
      $email_message = new \sendpost\model\EmailMessage(); 
      $email_message->setSubject('Hello World');
      $email_message->setHtmlBody('<strong>it works!</strong>');
      $email_message->setIppool('PiedPiper');
      $from = new \sendpost\model\From();
      $from->setEmail('[email protected]');

      $to = new \sendpost\model\To();
      $to->setEmail('[email protected]');
      $email_message->setTo(array($to));
      $email_message->setFrom($from);

      try {
          $result = $apiInstance->sendEmail($x_sub_account_api_key, $email_message);
          print_r($result);
      } catch (Exception $e) {
          echo 'Exception when calling EmailApi->sendEmail: ', $e->getMessage(), PHP_EOL;
      }