예제 #1
0
 public function actionWriteindex()
 {
     $model = new mail();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         error_reporting(E_ALL ^ E_WARNING);
         $request = Yii::$app->request;
         $body = $request->post();
         $to = $model->receiver;
         //            $text=$model->text;
         $subject = $model->subject;
         //            $body = $model->body;
         print_r($model);
         $mail = new sendmail();
         //新建发送
         $mail->setServer("smtp.126.com", "tclrg", "Luanruitest");
         $mail->setFrom("*****@*****.**");
         $mail->setReceiver("{$to}");
         $mail->setMailInfo($subject, $body['body'], false, NULL);
         $mail->sendMail();
         return $this->render('/Users\\dealer\\write', ['model' => $model]);
     } else {
         //print_r($model);
         return $this->render('/Users\\dealer\\write', ['model' => $model]);
     }
 }