PHP code example of grizzlylab / mailer-bundle

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

    

grizzlylab / mailer-bundle example snippets


// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        //...
        new Grizzlylab\Bundle\MailerBundle\GrizzlylabMailerBundle()
        //...

$container->get('grizzlylab_mailer')->send('@AcmeUser/Mail/awesome.txt.twig', $emails);

$container->get('grizzlylab_mailer')->send('@AcmeUser/Mail/awesome.txt.twig', $emails, null, [], false);

//send($content, $addresses, $subject = null, array $templateParameters = [], $contentIsATemplate = true, array $sender = null)
//If the content is a template and if the subject is null, we use the first line of the template as the subject && the rest as the body

// for a single recipient, second arguement is a string (e.g. '[email protected]')
$this->container->get('grizzlylab_mailer')->send($content, $address);

// for multiple recipients, second arguement is an array
$this->container->get('grizzlylab_mailer')->send($content, $addresses);

// you can override the sender 
$sender = ['address' => [email protected], 'name' => 'GrizzlyLab'];
$this->container->get('grizzlylab_mailer')->send($content, $addresses, $sender);

// the return value is the number of recipients who were accepted for delivery
$numberOfAcceptedRecipients = $this->container->get('grizzlylab_mailer')->send($content, $addresses, $sender);