public function send()
    {
        if (!$this->_user->has('email') || !$this->_user->has('name')) {
            throw new BadMethodCallException(__d('user', 'Missing "name" or "email" property when trying to send the email.'));
        }

        if ($this->config('updateToken') === true) {
            $this->loadModel('User.Users');
            $this->_user->updateToken();
        }

        $subject = $this->_parseVariables((string)$this->subject());
        $body = $this->_parseVariables((string)$this->body());

        if (empty($subject) || empty($body)) {
            return false;
        }

        $sender = new Email($this->config('emailConfig'));
        $sent = false;
        try {
            $sent = $sender
                ->to($this->_user->get('email'), $this->_user->get('name'))
                ->subject($subject)
                ->send($body);
        } catch (\Exception $e) {
            return false;
        }

        return $sent;
    }
public function send()
    {
        if (!$this->_user->has('email') || !$this->_user->has('name')) {
            throw new BadMethodCallException(__d('user', 'Missing "name" or "email" property when trying to send the email.'));
        }

        if ($this->config('updateToken') === true) {
            $this->loadModel('User.Users');
            $this->_user->updateToken();
        }

        $subject = $this->_parseVariables((string)$this->subject());
        $body = $this->_parseVariables((string)$this->body());

        if (empty($subject) || empty($body)) {
            return false;
        }

        $sender = new Email($this->config('emailConfig'));
        $sent = false;
        try {
            $sent = $sender
                ->to($this->_user->get('email'), $this->_user->get('name'))
                ->subject($subject)
                ->send($body);
        } catch (\Exception $e) {
            return false;
        }

        return $sent;
    }
public function send ( ) { if ( ! $ this -> _user -> has ( 'email' ) || ! $ this -> _user -> has ( 'name' ) ) { throw new BadMethodCallException ( __d ( 'user' , 'Missing "name" or "email" property when trying to send the email.' ) ) ; } if ( $ this -> config ( 'updateToken' ) === true ) { $ this -> loadModel ( 'User.Users' ) ; $ this -> _user -> updateToken ( ) ; } $ subject = $ this -> _parseVariables ( ( string ) $ this -> subject ( ) ) ; $ body = $ this -> _parseVariables ( ( string ) $ this -> body ( ) ) ; if ( empty ( $ subject ) || empty ( $ body ) ) { return false ; } $ sender = new Email ( $ this -> config ( 'emailConfig' ) ) ; $ sent = false ; try { $ sent = $ sender -> to ( $ this -> _user -> get ( 'email' ) , $ this -> _user -> get ( 'name' ) ) -> subject ( $ subject ) -> send ( $ body ) ; } catch ( \ Exception $ e ) { return false ; } return $ sent ; }
Sends email message to user.

@return bool True on success, false otherwise
@throws \BadMethodCallException When "name" or "email" properties are missing
for the provided User entity
Sends email message to user .