/** * 发送email方法 * 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())) { $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) { $mail = Yii::$app->mailer->compose(); $mail->setTo($model->receiver_email); $mail->setSubject($model->subject); $mail->setHtmlBody($model->content); $mail->attach($model->attachment); } else { $value = Yii::$app->mailer->compose(); $mail->setTo($model->receiver_email); $mail->setSubject($model->subject); $mail->setHtmlBody($model->content); } if ($mail->send()) { $model->save(); } return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * 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())) { //send the email //get the company email and the company name // $company = Companies::findOne(Yii::$app->user->identity->companies_company_id); //upload the attachment $model->attachment = UploadedFile::getInstance($model, 'attachment'); if ($model->attachment) { $imageName = time(); $imagePath = 'attachments/' . $imageName . '.' . $model->attachment->extension; $model->attachment->saveAs($imagePath); $model->attachment = $imagePath; } if ($model->attachment) { $value = Yii::$app->mailer->compose()->setFrom(['*****@*****.**' => 'MarcosKubas'])->setTo($model->receiver_email)->setSubject($model->subject)->setHtmlBody($model->content)->attach($model->attachment)->send(); } else { $value = Yii::$app->mailer->compose()->setFrom(['*****@*****.**' => 'MarcosKubas'])->setTo($model->receiver_email)->setSubject($model->subject)->setHtmlBody($model->content)->send(); } $model->save(); // print_r($model->getErrors()); return $this->redirect(['view', 'id' => $model->email_id]); } else { return $this->render('create', ['model' => $model]); } }
/** * 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())) { $model->attachment = UploadedFile::getInstance($model, 'attachment'); print_r($_POST); // print_r($_FILES); // die; if ($model->attachment) { $time = time(); $model->attachment->saveAs('uploads/' . $time . $model->attachment->extension); $model->attachment = 'uploads/' . $time . '.' . $model->attachment->extension; } print_r($model->attachment); // print_r($_FILES); die; if ($model->attachment) { $value = Yii::$app->mailer->compose()->setFrom(['*****@*****.**' => 'DoingItEasyChannel'])->setTo($model->reciever_email)->setSubject($model->subject)->setHtmlBody($model->conntent)->attach($model->attachment)->send(); } else { // $value = Yii::$app->mailer->compose() // ->setFrom(['*****@*****.**'=>'DoingItEasyChannel']) // ->setTo($model->reciever_email) // ->setSubject($model->subject) // ->setHtmlBody($model->conntent) // ->send(); } $model->save(); print_r($model->getErrors()); die('y'); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * 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()) && $model->save()) { return $this->redirect(['view', 'id' => $model->IdEmail]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Emails model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($emp_id = null, $mode = null) { $model = new Emails(); $model->employee_id = $emp_id; $model->status = 1; if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($emp_id == null) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->redirect(['employees/view', 'id' => $emp_id, 'mode' => $mode]); } } else { return $this->render('create', ['model' => $model]); } }
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) { $value = Yii::$app->mailer->compose()->setFrom(['*****@*****.**' => 'parasseuxVitths'])->setTo($model->receiver_email)->setSubject($model->subject)->setHtmlBody($model->content)->attach($model->attachment)->send(); } else { $value = Yii::$app->mailer->compose()->setFrom(['*****@*****.**' => 'Vitthal Mirji'])->setTo($model->receiver_email)->setSubject($model->subject)->setHtmlBody($model->content)->send(); } $model->save(); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * 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())) { // override php.ini ini_set('max_execution_time', 600); // 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) { $value = Yii::$app->mailer->compose()->setFrom(['*****@*****.**' => 'YiiHey'])->setTo($model->receiver_email)->setSubject($model->subject)->setHtmlBody($model->content)->attach($model->attachment)->send(); } else { $value = Yii::$app->mailer->compose()->setFrom(['*****@*****.**' => 'YiiHey'])->setTo($model->receiver_email)->setSubject($model->subject)->setHtmlBody($model->content)->send(); } $model->save(); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }