PHP code example of tourze / email-direct-marketing-bundle

1. Go to this page and download the library: Download tourze/email-direct-marketing-bundle 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/ */

    

tourze / email-direct-marketing-bundle example snippets


return [
    // ...
    EmailDirectMarketingBundle\EmailDirectMarketingBundle::class => ['all' => true],
];

use EmailDirectMarketingBundle\Entity\Task;
use EmailDirectMarketingBundle\Entity\Template;
use EmailDirectMarketingBundle\Enum\TaskStatus;

// Create a template
$template = new Template();
$template->setName('Welcome Email');
$template->setSubject('Welcome to ${receiver.getName()}!');
$template->setHtmlBody('<h1>Hello ${receiver.getName()}</h1>');

// Create a task
$task = new Task();
$task->setTitle('Welcome Campaign');
$task->setTemplate($template);
$task->setTags(['new-users']);
$task->setStartTime(new \DateTimeImmutable('+1 hour'));
$task->setStatus(TaskStatus::WAITING);

use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

class CustomVariableProvider
{
    public function addVariables(ExpressionLanguage $expressionLanguage): void
    {
        $expressionLanguage->register('customVar', 
            function () {
                return 'your custom value';
            },
            function ($arguments) {
                return 'your custom value';
            }
        );
    }
}
bash
php bin/console doctrine:migrations:migrate