PHP code example of beebmx / kirby-courier

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

    

beebmx / kirby-courier example snippets


use Beebmx\KirbyCourier\Notification\Message;

(new Message)
    ->to('[email protected]')
    ->line('Welcome to Kirby Courier')
    ->action('Visit', 'https://beeb.mx')
    ->send()

use Beebmx\KirbyCourier\Notification\Message;

(new Message)
    ->to('[email protected]')
    ->greeting('Hello friend!')
    ->line('Welcome to Kirby Courier')
    ->line('You can add more lines before an action')
    ->lines(['Multiple line 01', 'Multiple line 02'])
    ->lineIf($someCondition === true, 'You can add more lines before an action')
    ->linesIf($someCondition === false, ['Line 03', 'Line 04'])
    ->success()         // To set the action button as successful
    ->error()           // To set the action button as an error
    ->action('Action button', 'https://beeb.mx')
    ->line('You can add lines after an action')
    ->salutation('Good bye!')
    ->send()

use Beebmx\KirbyCourier\Mail\Message;

(new Message)
    ->to('[email protected]')
    ->template('marketing')
    ->send()

/*** /site/template/courier/marketing.php ***/

 snippet('courier/message', slots: true) 

use Beebmx\KirbyCourier\Mail\Message;

(new Message)
    ->preset('contact')                     // The preset should be available in your config.php file
    ->from('[email protected]')
    ->from('[email protected]', 'Webmaster')  // You can add a name to from address
    ->to('[email protected]')
    ->to('[email protected]')                     // You can add multiple recipients (TO)
    ->cc('[email protected]')
    ->cc('[email protected]')                     // You can add multiple recipients (CC)
    ->bcc('[email protected]')
    ->bcc('[email protected]')                    // You can add multiple recipients (BCC)
    ->replyTo('[email protected]')
    ->subject('Thank you for your contact request')
    ->theme('dark')                         // The theme should be available in your themes
    ->data(['name' => 'John Doe', 'position' => 'CEO']) // All the data available for the template
    ->attach($page->file('image.jpg'))
    ->attach($page->file('file.pdf'))       // You can add multiple files
    ->attachMany([$page->file('file.pdf'), $page->file('file.jpg')])
    ->render()                              // Returns a Content instance to visualize
    ->send()                                // Trigger to send the email

<?= (new Beebmx\KirbyCourier\Mail\Message)
    ->template('marketing')
    ->data(['name' => 'John Doe'])
    ->render()
    ->toHtml() 

 snippet('courier/button', ['url' => ''], slots: true) 

 snippet('courier/panel', slots: true) 

 snippet('courier/table', slots: true) 

 snippet('courier/subcopy', slots: true) 

courier('notification')
    ->to('[email protected]')
    ->line('This is a line')
    ->send()

courier('mail')
    ->to('[email protected]')
    ->template('marketing')
    ->send()

<?= courier('mail')
        ->template('marketing')
        ->render()
        ->toHtml() 

'beebmx.kirby-courier' => [
    'logo' => function() {
        return site()->file('logo.png');
    },
    'path' => 'courier',
    'from' => [
        'address' => '[email protected]',
        'name' => 'Example',
    ],
    'message' => [
        'greeting' => 'Hello friend!',
        'rights' => 'Copyrights.',
        'salutation' => 'Thanks',
        'subject' => 'Message from courier',
        'notify' => 'Si tienes problemas para hacer clic en el botón, copia y pega la URL de abajo en tu navegador web.',
        'brand_name' => null,
    ],
],