PHP code example of mikejestes / ornamental

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

    

mikejestes / ornamental example snippets


$setup = \Ornamental\Settings::getInstance();
$setup->templateDir = __DIR__ . '/templates/';
$setup->layoutDir = __DIR__ . '/layouts/';
$setup->messageDir = __DIR__ . '/messages/';

// optionally prefix emails with a string
$setup->subjectPrefix = '[test] ';

// set default variables across all messages
$setup->defaults = array(
    'website_url' => 'http://example.com/',
);

// add phpmailer sender
$phpmailer = new \Ornamental\Sender\Phpmailer();
$phpmailer->smtpHost = 'smtp.example.com';
$phpmailer->smtpUsername = 'root';
$phpmailer->smtpPassword = 'password';

$setup->addSender($phpmailer);

//  \Ornamental\Sender\Logger is a sender that logs to a PSR logger class
$setup->addSender(new \Ornamental\Sender\Logger($logger));

$email = new \Ornamental\Message('user_welcome');
$email->user = array('name' => "Joe User");
$email->send();

$deliveries = \Ornamental\Deliveries::getInstance();
$this->assertEquals(2, count($deliveries->log));