models/CallbackForm.php
/**
     * @param string $email the target email address
     * @return bool whether the model passes validation
     */
@param string $email the target email address
@return bool whether the model passes validation
@param string $email the target email address @return bool whether the model passes validation
public function send($email)
    {
        $text = $this->name . ' ' . $this->phone;
        if ($this->validate()) {
            try {
                Yii::$app->mailer->compose()
                    ->setTo($email)
                    ->setFrom([Yii::$app->params['fromEmail'] => Yii::$app->name])
                    ->setSubject(Yii::t('app', 'Callback'))
                    ->setTextBody($text)
                    ->send();
            } catch (Exception $e) {
                Yii::$app->mailer2->compose()
                    ->setTo($email)
                    ->setFrom([Yii::$app->params['fromEmail'] => Yii::$app->name])
                    ->setSubject('Ошибка отправки почты. ' . Yii::t('app', 'Callback'))
                    ->setTextBody('Ошибка отправки почты, сообщите разработчику. ' . $text)
                    ->send();
            }
            return true;
        }
        return false;
    }
public function send ( $ email ) { $ text = $ this -> name . ' ' . $ this -> phone ; if ( $ this -> validate ( ) ) { try { Yii :: $ app -> mailer -> compose ( ) -> setTo ( $ email ) -> setFrom ( [ Yii :: $ app -> params [ 'fromEmail' ] => Yii :: $ app -> name ] ) -> setSubject ( Yii :: t ( 'app' , 'Callback' ) ) -> setTextBody ( $ text ) -> send ( ) ; } catch ( Exception $ e ) { Yii :: $ app -> mailer2 -> compose ( ) -> setTo ( $ email ) -> setFrom ( [ Yii :: $ app -> params [ 'fromEmail' ] => Yii :: $ app -> name ] ) -> setSubject ( 'Ошибка отправки почты. ' . Yii::t('app', 'C l bac k' ) ) -> setTextBody ( 'Ошибка отправки почты, сообщите разработчику. ' . $text) -> send ( ) ; } return true ; } return false ; }
@param string $email the target email address
 @return bool whether the model passes validation
@param string $email the target email address @return bool whether the model passes validation