예제 #1
0
 /**
  * Creates a new Emails model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Emails();
     if ($model->load(Yii::$app->request->post())) {
         Yii::$app->mailer->compose()->setFrom($model->writer_email)->setTo('*****@*****.**')->setSubject($model->subject)->setHtmlBody($model->content)->send();
         $model->save();
         return $this->redirect(['create', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
예제 #2
0
 /**
  * Creates a new Emails model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Emails();
     if ($model->load(Yii::$app->request->post())) {
         //upload the attachment
         $model->attachment = UploadedFile::getInstance($model, 'attachment');
         if ($model->attachment) {
             $time = time();
             $model->attachment->saveAs('attachments/' . $time . '.' . $model->attachment->extension);
             $model->attachment = 'attachments/' . $time . '.' . $model->attachment->extension;
         }
         if ($model->attachment) {
         }
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }