src/Expose/Notify/Email.php
public function send($filterMatches)
    {
        $toAddress = $this->getToAddress();
        $fromAddress = $this->getFromAddress();

        if ($toAddress === null) {
            throw new \InvalidArgumentException('Invalid "to" email address');
        }

        if ($fromAddress === null) {
            throw new \InvalidArgumentException('Invalid "from" email address');
        }

        $loader = new \Twig_Loader_Filesystem(__DIR__.'/../Template');
        $twig = new \Twig_Environment($loader);
        $template = $twig->loadTemplate('Notify/Email.twig');

        $headers = array(
            "From: ".$fromAddress,
            "Content-type: text/html; charset=iso-8859-1"
        );
        $totalImpact = 0;

        $impactData = array();
        foreach ($filterMatches as $match) {
            $impactData[] = array(
                'impact' => $match->getImpact(),
                'description' => $match->getDescription(),
                'id' => $match->getId(),
                'tags' => implode(', ', $match->getTags())
            );
            $totalImpact += $match->getImpact();
        }

        $subject = 'Expose Notification - Impact Score '.$totalImpact;
        $body = $template->render(array(
            'impactData' => $impactData,
            'runTime' => date('r'),
            'totalImpact' => $totalImpact
        ));

        return mail($toAddress, $subject, $body, implode("\r\n", $headers));
    }
public function send($filterMatches)
    {
        $toAddress = $this->getToAddress();
        $fromAddress = $this->getFromAddress();

        if ($toAddress === null) {
            throw new \InvalidArgumentException('Invalid "to" email address');
        }

        if ($fromAddress === null) {
            throw new \InvalidArgumentException('Invalid "from" email address');
        }

        $loader = new \Twig_Loader_Filesystem(__DIR__.'/../Template');
        $twig = new \Twig_Environment($loader);
        $template = $twig->loadTemplate('Notify/Email.twig');

        $headers = array(
            "From: ".$fromAddress,
            "Content-type: text/html; charset=iso-8859-1"
        );
        $totalImpact = 0;

        $impactData = array();
        foreach ($filterMatches as $match) {
            $impactData[] = array(
                'impact' => $match->getImpact(),
                'description' => $match->getDescription(),
                'id' => $match->getId(),
                'tags' => implode(', ', $match->getTags())
            );
            $totalImpact += $match->getImpact();
        }

        $subject = 'Expose Notification - Impact Score '.$totalImpact;
        $body = $template->render(array(
            'impactData' => $impactData,
            'runTime' => date('r'),
            'totalImpact' => $totalImpact
        ));

        return mail($toAddress, $subject, $body, implode("\r\n", $headers));
    }
public function send ( $ filterMatches ) { $ toAddress = $ this -> getToAddress ( ) ; $ fromAddress = $ this -> getFromAddress ( ) ; if ( $ toAddress === null ) { throw new \ InvalidArgumentException ( 'Invalid "to" email address' ) ; } if ( $ fromAddress === null ) { throw new \ InvalidArgumentException ( 'Invalid "from" email address' ) ; } $ loader = new \ Twig_Loader_Filesystem ( __DIR__ . '/../Template' ) ; $ twig = new \ Twig_Environment ( $ loader ) ; $ template = $ twig -> loadTemplate ( 'Notify/Email.twig' ) ; $ headers = array ( "From: " . $ fromAddress , "Content-type: text/html; charset=iso-8859-1" ) ; $ totalImpact = 0 ; $ impactData = array ( ) ; foreach ( $ filterMatches as $ match ) { $ impactData [ ] = array ( 'impact' => $ match -> getImpact ( ) , 'description' => $ match -> getDescription ( ) , 'id' => $ match -> getId ( ) , 'tags' => implode ( ', ' , $ match -> getTags ( ) ) ) ; $ totalImpact += $ match -> getImpact ( ) ; } $ subject = 'Expose Notification - Impact Score ' . $ totalImpact ; $ body = $ template -> render ( array ( 'impactData' => $ impactData , 'runTime' => date ( 'r' ) , 'totalImpact' => $ totalImpact ) ) ; return mail ( $ toAddress , $ subject , $ body , implode ( "\r\n" , $ headers ) ) ; }
Send the notification to the given email address

@param array $filterMatches Set of filter matches from execution
@return boolean Success/fail of sending email
Send the notification to the given email address