src/Email.php
public function send(array $vars = array())
    {
        if (count($this->getTo()) == 0) {
            throw new \InvalidArgumentException('A "To" email address is requried');
        }
        
        if ($this->getSubject() == '') {
            throw new \InvalidArgumentException('A subject for the email must be set');
        }
        
        if ($this->getMessage() == '') {
            throw new \InvalidArgumentException('There isn\'t a message set');
        }
        
        $valid_emails = array();
        foreach ($this->getTo() as $to) {
            if (filter_var(trim($to), FILTER_VALIDATE_EMAIL)) {
                $valid_emails[] = trim($to);
            }
        }
        
        if (! $valid_emails) {
            return;
        }
        
        $mailer = $this->getMailer();
        $subject = $this->getView()->render($this->getSubject(), $vars);
        $body_message = $this->getView()->render($this->getMessage(), $vars);
        $message = $mailer->getMessage($valid_emails, $this->config['from_email'], $this->config['sender_name'], $subject, $body_message, $this->getAttachments(), $this->getMailtype());
        
        if (! $mailer->send($message)) {
            throw new EmailException($this->getMailer()->ErrorInfo);
        }
        
        $this->clear();
    }
public function send(array $vars = array())
    {
        if (count($this->getTo()) == 0) {
            throw new \InvalidArgumentException('A "To" email address is requried');
        }
        
        if ($this->getSubject() == '') {
            throw new \InvalidArgumentException('A subject for the email must be set');
        }
        
        if ($this->getMessage() == '') {
            throw new \InvalidArgumentException('There isn\'t a message set');
        }
        
        $valid_emails = array();
        foreach ($this->getTo() as $to) {
            if (filter_var(trim($to), FILTER_VALIDATE_EMAIL)) {
                $valid_emails[] = trim($to);
            }
        }
        
        if (! $valid_emails) {
            return;
        }
        
        $mailer = $this->getMailer();
        $subject = $this->getView()->render($this->getSubject(), $vars);
        $body_message = $this->getView()->render($this->getMessage(), $vars);
        $message = $mailer->getMessage($valid_emails, $this->config['from_email'], $this->config['sender_name'], $subject, $body_message, $this->getAttachments(), $this->getMailtype());
        
        if (! $mailer->send($message)) {
            throw new EmailException($this->getMailer()->ErrorInfo);
        }
        
        $this->clear();
    }
public function send ( array $ vars = array ( ) ) { if ( count ( $ this -> getTo ( ) ) == 0 ) { throw new \ InvalidArgumentException ( 'A "To" email address is requried' ) ; } if ( $ this -> getSubject ( ) == '' ) { throw new \ InvalidArgumentException ( 'A subject for the email must be set' ) ; } if ( $ this -> getMessage ( ) == '' ) { throw new \ InvalidArgumentException ( 'There isn\'t a message set' ) ; } $ valid_emails = array ( ) ; foreach ( $ this -> getTo ( ) as $ to ) { if ( filter_var ( trim ( $ to ) , FILTER_VALIDATE_EMAIL ) ) { $ valid_emails [ ] = trim ( $ to ) ; } } if ( ! $ valid_emails ) { return ; } $ mailer = $ this -> getMailer ( ) ; $ subject = $ this -> getView ( ) -> render ( $ this -> getSubject ( ) , $ vars ) ; $ body_message = $ this -> getView ( ) -> render ( $ this -> getMessage ( ) , $ vars ) ; $ message = $ mailer -> getMessage ( $ valid_emails , $ this -> config [ 'from_email' ] , $ this -> config [ 'sender_name' ] , $ subject , $ body_message , $ this -> getAttachments ( ) , $ this -> getMailtype ( ) ) ; if ( ! $ mailer -> send ( $ message ) ) { throw new EmailException ( $ this -> getMailer ( ) -> ErrorInfo ) ; } $ this -> clear ( ) ; }
Sends the email

@param array $vars
@throws \InvalidArgumentException
@throws \InvalidArgumentException
@throws EmailException
Sends the email