PHP code example of vegvisir / el-client

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

    

vegvisir / el-client example snippets



use EmailLabs\EmailLabs;

// Create new EmailLabs client
$el = new EmailLabs($appKey, $secretKey, $smtpAccount);

// Create new message without template
$msg1 = $el->message([
  'to' => '[email protected]',
  'to_message_id' => 'mid@domain',
  'subject' => 'Test message',
  'from' => '[email protected]',
  'text' => 'Test message body',
  'html' => '<h1>Test message body</h1>',
]);

// Create new message with template
$msg2 = $el->messageWithTemplate([
  'to' => '[email protected]',
  'to_name' => 'sigrun',
  'to_message_id' => 'mid@domain',
  'subject' => 'Test message',
  'from' => '[email protected]',
  'global_vars' => [
    'firstname' => 'John',
    'lastname' => 'Doe',
  ],
  'template_id' => 'el_template_id',
]);

// Send messages

$el->send([$msg1, $msg2]);

// or

$el->send($msg1);
$el->send($msg2);