public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
             Yii::$app->session->setFlash('success', yii::t('adminlte', 'Thank you for contacting us. We will respond to you as soon as possible.'));
         } else {
             Yii::$app->session->setFlash('error', yii::t('adminlte', 'There was an error sending email.'));
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
 public function testContact()
 {
     $model = new ContactForm();
     $model->attributes = ['name' => 'Tester', 'email' => '*****@*****.**', 'subject' => 'very important letter subject', 'body' => 'body of current message'];
     $model->sendEmail('*****@*****.**');
     $this->specify('email should be send', function () {
         expect('email file should exist', file_exists($this->getMessageFile()))->true();
     });
     $this->specify('message should contain correct data', function () use($model) {
         $emailMessage = file_get_contents($this->getMessageFile());
         expect('email should contain user name', $emailMessage)->contains($model->name);
         expect('email should contain sender email', $emailMessage)->contains($model->email);
         expect('email should contain subject', $emailMessage)->contains($model->subject);
         expect('email should contain body', $emailMessage)->contains($model->body);
     });
 }