Yii2:无法从表单发送电子邮件

<div class="status-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model,'job_code')->widget(Select2::classname(),[
            'data'=>ArrayHelper::map(CreateJob::find()->all(),'job_id','job_code'),
            'language'=>'en',
            'options'=>['placeholder' => 'Select Job Code','id'=>'empCode'],
            'pluginOptions' =>[

            ],
        ]); ?>

    <?= $form->field($model, 'job_code')->hiddenInput()->label(false); ?>

    <?= $form->field($model, 'client_code')->textInput(['readonly' => true]) ?>

    <?= $form->field($model, 'company_name')->textInput(['readonly' => true]) ?>

    <?= $form->field($model, 'emp_email')->hiddenInput()->label(false); ?>

    <?= $form->field($model, 'emp_mobile')->hiddenInput()->label(false); ?>

    <?= $form->field($model, 'emp_first_name')->hiddenInput()->label(false); ?>

    <?= $form->field($model, 'emp_last_name')->hiddenInput()->label(false); ?>

    <?= $form->field($model, 'job_description')->textarea(['rows' => 6]) ?>

    <?= $form->field($model, 'status')->radioList(array('Approved'=>'Approved','Digital'=>'Digital','CDP'=>'CDP','Print'=>'Print','Other Process'=>'Other Process','Packing'=>'Packing','Dispatch'=>'Dispatch'),['class' => $model->status ? 'btn-group' : 'btn btn-default'],array('onChange'=>'toggleSSN();'),['id'=>'radioButtons'] );                   ?>


    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>

Controller

public function actionCreate()
    {
        $model = new Status();
       $email = new Emails();

        if ($model->load(Yii::$app->request->post())) 
        {

                $value=Yii::$app->mailer->compose()
                ->setFrom(["xyz@gmail.com"])
                ->setTo($model->emp_email)
                ->setsubject('Job Status')
                ->setHtmlBody($model->job_description)
                ->send();

            $model->save();
            $email->save();

            return $this->redirect(['view', 'id' => $model->id]);
        } 
        else 
        {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }

I want to send Email to the client about its current status of job. When user will paste submit it should send email to the client from filled form fields. Also I need to set template for this email so that only client information will change no other part.

You have unnecessary code where you are trying to display boolean value in your view, remove this:

<?= 
Yii::$app->mailer->compose()
->setFrom('xyz@gmail.com')
->setTo('abc@hotmail.com')
->setSubject('Message subject')
->setTextBody('Plain text content')
->setHtmlBody('<b>HTML content</b>')
->send();
?>

You should check what value returns your sending function by var_dump($value) in your controller, if it return false there is high probability that your server is not proper configured.

If you are using Ubuntu, read "How to install ssmtp" and "How to configure ssmtp" from: http://www.havetheknowhow.com/Configure-the-server/Install-ssmtp.html

First Remove div class="active form" from submit button then button will work.

<div class="form-group">
    <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>

to

<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>