PHP code example of extellient / mail-bundle

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

    

extellient / mail-bundle example snippets


// app/AppKernel.php Symfony 3.4+
public function registerBundles()
{
    $bundles = array(
        //...
        new Extellient\MailBundle\MailBundle(),
        //...
    );

// config/bundles.php Symfony 4+

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


// src/controller/HomeController.php




namespace App\Controller;


use Extellient\MailBundle\Services\MailTemplating;
use Extellient\MailBundle\Services\Mailer;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;

/**
 * Class HomeController
 * @package App\Controller
 */
class HomeController extends Controller
{
    /**
     * Create your mail from a template
     * @Route("/", name="home")
     * @param MailTemplating $mailTemplating
     */
    public function indexAction(MailTemplating $mailTemplating)
    {
        $mail = $mailTemplating->createEmail('your_template', '[email protected]', [
            'variable_twig' => 'test'
        ]);
        $mailTemplating->getMailService()->save($mail);
    }

    /**
     * Create your mail without a template
     * @Route("/mail", name="home")
     * @param Mailer $mailer
     */
    public function mailAction(Mailer $mailer)
    {
        $mail = $mailer->createEmail('subject', 'body', '[email protected]');
        $mailer->save($mail);
    }

}

bash
#Symfony 3.4+
php bin/console doctrine:migrations:update
bash
php bin/console extellient:mail:send