PHP code example of flowmailer / flowmailer-php-sdk

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

    

flowmailer / flowmailer-php-sdk example snippets




lowmailer\API\Enum\MessageType;
use Flowmailer\API\Flowmailer;
use Flowmailer\API\Model\SubmitMessage;

// The credentials can be obtained in your Flowmailer account
$accountId    = '...';
$clientId     = '...';
$clientSecret = '...';

$flowmailer = Flowmailer::init($accountId, $clientId, $clientSecret);

$submitMessage = (new SubmitMessage())
    ->setMessageType(MessageType::EMAIL)
    ->setSubject('An e-mail message')
    ->setRecipientAddress('[email protected]')
    ->setSenderAddress('[email protected]')
;



use Flowmailer\API\Collection\MessageCollection;

$flowmailer           = Flowmailer::init($accountId, $clientId, $clientSecret);
$pageSize             = 100;
$savedReferenceOrNull = null; // Get reference from database or cache (null will start from the beginning of the list)
$referenceRange       = new ReferenceRange($pageSize, $savedReferenceOrNull);

while ($referenceRange instanceof ReferenceRange) {
    /** @var MessageCollection $result */
    $result = $flowmailer->getMessages($referenceRange);

    // Do stuff with the result here

    // Store $referenceRange->getReference() value here in database or cache as input for a future run
    // Now we set the ReferenceRange for the next loop in memory
    $referenceRange = $result->getNextRange();
}
bash
$ composer