public function process($email, $fromName, $fromEmail, $maxAttempts)
    {
        try {
            if ($this->send($email, $fromName, $fromEmail)) {
                $this
                    ->db
                    ->createCommand()
                    ->update(
                        $this->queueTable,
                        ['status' => Email::STATUS_SENT],
                        ['id' => $email['id']]
                    )
                    ->execute();
                return true;
            }

            $attempt = $email['attempt'] + 1;
            if ($attempt <= $maxAttempts) {
                $this
                    ->db
                    ->createCommand()
                    ->update(
                        $this->queueTable,
                        ['attempt' => $attempt],
                        ['id' => $email['id']]
                    )
                    ->execute();
            } else {
                $this
                    ->db
                    ->createCommand()
                    ->update(
                        $this->queueTable,
                        ['status' => Email::STATUS_GAVEUP],
                        ['id' => $email['id']]
                    )
                    ->execute();
            }
        } catch (Exception $e) {
            Log::error($e->getMessage(), null, __METHOD__);
        }
        return false;
    }
public function process($email, $fromName, $fromEmail, $maxAttempts)
    {
        try {
            if ($this->send($email, $fromName, $fromEmail)) {
                $this
                    ->db
                    ->createCommand()
                    ->update(
                        $this->queueTable,
                        ['status' => Email::STATUS_SENT],
                        ['id' => $email['id']]
                    )
                    ->execute();
                return true;
            }

            $attempt = $email['attempt'] + 1;
            if ($attempt <= $maxAttempts) {
                $this
                    ->db
                    ->createCommand()
                    ->update(
                        $this->queueTable,
                        ['attempt' => $attempt],
                        ['id' => $email['id']]
                    )
                    ->execute();
            } else {
                $this
                    ->db
                    ->createCommand()
                    ->update(
                        $this->queueTable,
                        ['status' => Email::STATUS_GAVEUP],
                        ['id' => $email['id']]
                    )
                    ->execute();
            }
        } catch (Exception $e) {
            Log::error($e->getMessage(), null, __METHOD__);
        }
        return false;
    }
public function process ( $ email , $ fromName , $ fromEmail , $ maxAttempts ) { try { if ( $ this -> send ( $ email , $ fromName , $ fromEmail ) ) { $ this -> db -> createCommand ( ) -> update ( $ this -> queueTable , [ 'status' => Email :: STATUS_SENT ] , [ 'id' => $ email [ 'id' ] ] ) -> execute ( ) ; return true ; } $ attempt = $ email [ 'attempt' ] + 1 ; if ( $ attempt <= $ maxAttempts ) { $ this -> db -> createCommand ( ) -> update ( $ this -> queueTable , [ 'attempt' => $ attempt ] , [ 'id' => $ email [ 'id' ] ] ) -> execute ( ) ; } else { $ this -> db -> createCommand ( ) -> update ( $ this -> queueTable , [ 'status' => Email :: STATUS_GAVEUP ] , [ 'id' => $ email [ 'id' ] ] ) -> execute ( ) ; } } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; }
Tries to send email from queue and updates its status.
@param string $email
@param string $fromName
@param string $fromEmail
@param int $maxAttempts
@return bool
Tries to send email from queue and updates its status .