PHP code example of gcgov / bulk-email

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

    

gcgov / bulk-email example snippets


\gcgov\framework\services\bulkEmail\config::setApiUrl( 'https://bulkemailapi.example.com' );
\gcgov\framework\services\bulkEmail\config::setApiAccessToken( '{jwt}' );

\gcgov\framework\services\bulkEmail\config::setDebugLogging( true );
\gcgov\framework\services\bulkEmail\config::setDebugLogPath( 'C:/inetpub/logs' );

//                                             messageToChannel( string[] $emailAddresses,   string[] $channelIds=[] )
\gcgov\framework\services\bulkEmail\bulkEmail::messageToChannel( ['[email protected]'], [ '64f1e3a45d0afbf5408370cc' ] );

$message            = new \gcgov\framework\services\bulkEmail\models\messageToChannel();

//wrap $message->message with this template
$message->template  = \gcgov\framework\services\bulkEmail\models\template::countyTemplate2023; 

//if the brand heading should use department information, specify the id of the department to use. To use a generic leave null)
//$message->sendingDepartmentId  = '{departmentId}';

//send this message to all subscribers to this channel
$message->channelId = '{channelId}';

//email subject line
$message->subject   = 'Subject';

//email html body - do not use full 
$message->message   = '<div>HTML message body</div>';

//a reference to the event/item that generated this message
$message->reference = 'website.article.id=1';

//send
\gcgov\framework\services\bulkEmail\bulkEmail::messageToChannel( $message );

$message            = new \gcgov\framework\services\bulkEmail\models\messageToEmail();

//wrap $message->message with this template
$message->template  = \gcgov\framework\services\bulkEmail\models\template::countyTemplate2023; 

//if the brand heading should use department information, specify the id of the department to use. To use a generic leave null)
//$message->sendingDepartmentId  = '{departmentId}';

//send this message to these email addresses
$message->to = ['[email protected]'];

//email subject line
$message->subject   = 'Subject';

//email html body - do not use full 
$message->message   = '<div>HTML message body</div>';

//a reference to the event/item that generated this message
$message->reference = 'payments.receipt.id=1';

//send
\gcgov\framework\services\bulkEmail\bulkEmail::messageToEmail( $message );