PHP code example of hautzi / system-mail-bundle

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

    

hautzi / system-mail-bundle example snippets


// from your code simply call
$container->get('system_mailer')->send('emails/send-info.xml.twig', [
    'user' => $user,
]);


// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Hautzi\SystemMailBundle\HautziSystemMailBundle(),
        );

        // ...
    }

    // ...
}

$systemMailer = $container->get('system_mailer');

// sends out AppBundle/Resources/emails/registration/confirmUser.xml.twig
$systemMailer->send('emails/registration/confirmUser.xml.twig', ['user' => $user]);

// force locale of sent mail (when the recipient speaks another language than the user in the session)
$systemMailer->send('emails/info-mail.xml.twig', ['user' => $user], 'de');

// attach file to mail (or do something else with the Swift_Message instance)
$systemMailer->send('emails/message-with-pdf.xml.twig', [], null, function (\Swift_Message $message) {
     $message->attach(\Swift_Attachment::fromPath('my-document.pdf'))
});