PHP code example of locomotivemtl / charcoal-email

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

    

locomotivemtl / charcoal-email example snippets


$email = $container['email'];
$email->setData([
    'campaign' => 'Campaign identifier'
    'to' => [
        '[email protected]',
        '"Some guy" <[email protected]>',
        [
            'name'  => 'Other guy',
            'email' => '[email protected]'
        ]
    ],
    'bcc' => '[email protected]'
    'from' => '"Company inc." <[email protected]>',
    'reply_to' => [
        'name' => 'Jack CEO',
        'email' => '[email protected]'
    ],
    'subject' => $this->translator->trans('Email subject'),
    'template_ident' => 'foo/email/default-email'
    'attachments' => [
        'foo/bar.pdf',
        'foo/baz.pdf'
    ]
]);
$email->send();

// Alternately, to send at a later date / use the queue system:
$email->queue('in 5 minutes');