frontend/models/ContactForm.php
/**
     * Send email to admininstation via contact form.
     *
     * @return bool true on success, false on failure
     */
Send email to admininstation via contact form.
@return bool true on success, false on failure
Send email to admininstation via contact form . @return bool true on success false on failure
public function send ()
    {
        if ($this->validate()) {
            $contactEmail = Yii::$app->config->get('App.ContactEmail');
            return Yii::$app->mailer->compose([
                'html' => 'contactUs-html',
                'text' => 'contactUs-text'
            ],[
                'message' => $this->message
            ])
            ->setFrom($this->email)
            ->setTo($contactEmail)
            ->setSubject($this->subject)
            ->send();
        } else {
            return false;
        }
    }
public function send ( ) { if ( $ this -> validate ( ) ) { $ contactEmail = Yii :: $ app -> config -> get ( 'App.ContactEmail' ) ; return Yii :: $ app -> mailer -> compose ( [ 'html' => 'contactUs-html' , 'text' => 'contactUs-text' ] , [ 'message' => $ this -> message ] ) -> setFrom ( $ this -> email ) -> setTo ( $ contactEmail ) -> setSubject ( $ this -> subject ) -> send ( ) ; } else { return false ; } }
Send email to admininstation via contact form.
Send email to admininstation via contact form .