PHP code example of herald-project / client-php

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

    

herald-project / client-php example snippets


use Herald\Client\Client as HeraldClient;
use Herald\Client\Message as HeraldMessage;

// get the client with explicit parameters
$herald = new HeraldClient(
    '[herald api username]',
    '[herald api password]',
    '[herald server uri]',
    '[herald transport, e.g. smtp]'),
    '[herald account]',
    '[herald library]',
);

// get the client by DSN

$herald = HeraldClient::fromDsn('https://username:[email protected]/myAccount/myLibrary/myTransport');


// check template existance.
if ($herald->templateExists('signup')) {
    // get the message
    $message = new HeraldMessage();
    // use the template
    $message->setTemplate('signup');
    // set to address
    $message->setToAddress($emailAddress, $customerName);
    // populate data
    $message->setData('firstname', 'Hongliang');
    $message->setData('nickname', 'exploder hater');
    // send
    $herald->send($message);
}

composer