Inheritance: extends yii\base\Model
Exemplo n.º 1
0
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
         \Yii::$app->common->sendMail($model->subject, $model->body);
     }
     return $this->render('contact', ['model' => $model]);
 }
Exemplo n.º 2
0
 /**
  * @param array $contactData
  */
 public function submit(array $contactData)
 {
     $contactForm = new ContactForm();
     foreach ($contactData as $field => $value) {
         $inputType = $field === 'body' ? 'textarea' : 'input';
         $this->actor->fillField($inputType . '[name="' . $contactForm->formName() . '[' . $field . ']"]', $value);
     }
     $this->actor->click('contact-button');
 }
Exemplo n.º 3
0
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load($_POST) && $model->contact(Yii::$app->params['adminEmail'])) {
         Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
         return $this->refresh();
     } else {
         return $this->render('contact', array('model' => $model));
     }
 }
Exemplo n.º 4
0
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 5
0
 public function actionFeedback()
 {
     $model = new ContactForm();
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail(Yii::$app->settings->get('main.supportEmail'))) {
             return 'Спасибо за ваше сообщение, мы обязательно ответим вам в ближайшее время.';
         } else {
             return 'Что то пошло не так :( Попробуйте позднее';
         }
     }
     return 'Что то пошло не так :(';
 }
Exemplo n.º 6
0
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
         $body = " <div>Body: <b> " . $model->body . " </b></div>";
         $body .= " <div>Email: <b> " . $model->email . " </b></div>";
         \Yii::$app->common->sendMail($model->subject, $body);
         print "Send success";
         die;
     }
     return $this->render("contact", ['model' => $model]);
 }
Exemplo n.º 7
0
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
         $body = '<div>Body: <b>' . $model->body . ' </b></div>';
         $body .= '<div>Email: <b>' . $model->email . ' </b></div>';
         \Yii::$app->common->sendMail($model->subject, $body);
         print 'Send success';
     }
     return $this->render('contact', ['model']);
     //return $this->render('inner');
 }
Exemplo n.º 8
0
 /**
  * Contact.
  */
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(\Yii::$app->request->post()) && $model->validate()) {
         $success = $model->sendEmail(\Yii::$app->params['adminEmail']);
         if ($success) {
             \Yii::$app->session->setFlash('success', 'Your message has been sent!');
             $this->refresh('#form');
         }
     }
     return $this->render('contact', ['model' => $model]);
 }
 /**
  * Displays the contact static page and sends the contact email.
  *
  * @return string|\yii\web\Response
  */
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->contact(Yii::$app->params['adminEmail'])) {
             Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
         } else {
             Yii::$app->session->setFlash('error', 'There was an error sending email.');
         }
         return $this->refresh();
     }
     return $this->render('contact', ['model' => $model]);
 }
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->contact(Yii::$app->params['adminEmail'])) {
             Yii::$app->getSession()->setFlash('alert', ['body' => Yii::t('frontend', 'Thank you for contacting us. We will respond to you as soon as possible.'), 'options' => ['class' => 'alert-success']]);
             return $this->refresh();
         } else {
             Yii::$app->getSession()->setFlash('alert', ['body' => \Yii::t('frontend', 'There was an error sending email.'), 'options' => ['class' => 'alert-danger']]);
         }
     }
     return $this->render('contact', ['model' => $model]);
 }
 /**
  * Displays the contact static page and sends the contact email.
  *
  * @return string|\yii\web\Response
  */
 public function actionContact()
 {
     $model = new ContactForm();
     if (!$model->load(Yii::$app->request->post()) || !$model->validate()) {
         return $this->render('contact', ['model' => $model]);
     }
     if (!$model->sendEmail(Yii::$app->params['adminEmail'])) {
         Yii::$app->session->setFlash('error', Yii::t('app', 'There was some error while sending email.'));
         return $this->refresh();
     }
     Yii::$app->session->setFlash('success', Yii::t('app', 'Thank you for contacting us. We will respond to you as soon as possible.'));
     return $this->refresh();
 }
Exemplo n.º 12
0
 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', 'Terima kasih sudah menghubungi kami. Pertanyaan anda akan kami jawab secepatnya.. ');
         } else {
             Yii::$app->session->setFlash('error', 'Maaf pesan gagal dikirim.coba ulangi lagi.');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 13
0
 /**
  * Displays contact page.
  *
  * @return mixed
  */
 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', ['type' => 'success', 'duration' => 12000, 'icon' => 'fa fa-envelope', 'message' => 'Thank you for contacting us. We will respond to you as soon as possible.', 'title' => 'Sending Message']);
         } else {
             Yii::$app->session->setFlash('error', ['type' => 'danger', 'duration' => 12000, 'icon' => 'fa fa-envelope', 'message' => 'There was an error sending email.', 'title' => 'Sending Message']);
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 14
0
 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', 'Obrigado pelo seu contacto! Recebrá uma resposta brevemente.');
         } else {
             Yii::$app->session->setFlash('error', 'Ocorreu um erro ao enviar o email!');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 15
0
 /**
  * Displays contact page.
  *
  * @return mixed
  */
 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', 'Cảm ơn bạn đã liên hệ với chúng tôi. Chúng tôi sẽ liên hệ lại với bạn trong thời gian sớm nhất.');
         } else {
             Yii::$app->session->setFlash('error', 'Có lỗi trong quá trình gửi mail.');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 16
0
 /**
  * Displays contact page.
  *
  * @return mixed
  */
 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('c/radiata/contact', 'Thank you'));
         } else {
             Yii::$app->session->setFlash('error', Yii::t('c/radiata/contact', 'Errors'));
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 17
0
 /**
  * Displays contact page.
  *
  * @return mixed
  */
 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', 'Спасибо за Ваше сообщение. Мы ответим вам при первой возможности.');
         } else {
             Yii::$app->session->setFlash('error', 'При отправке сообщения произошла ошибка.');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 18
0
 public function testSendEmail()
 {
     $model = new ContactForm();
     $model->attributes = ['name' => 'Tester', 'email' => '*****@*****.**', 'subject' => 'very important letter subject', 'body' => 'body of current message'];
     expect_that($model->sendEmail('*****@*****.**'));
     // using Yii2 module actions to check email was sent
     $this->tester->seeEmailIsSent();
     $emailMessage = $this->tester->grabLastSentEmail();
     expect('valid email is sent', $emailMessage)->isInstanceOf('yii\\mail\\MessageInterface');
     expect($emailMessage->getTo())->hasKey('*****@*****.**');
     expect($emailMessage->getFrom())->hasKey('*****@*****.**');
     expect($emailMessage->getSubject())->equals('very important letter subject');
     expect($emailMessage->toString())->contains('body of current message');
 }
Exemplo n.º 19
0
 /**
  * Displays contact page.
  *
  * @return mixed
  */
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
             Yii::$app->session->setFlash('success', 'Спасибо за обращение, мы ответим на ваше сообщение так быстро на сколько это возможно');
         } else {
             Yii::$app->session->setFlash('error', 'Произошла ошибка отправки письма');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 20
0
 /**
  * Displays contact page.
  *
  * @return mixed
  */
 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', 'Спасибо за обращение к нам. Мы ответим вам как можно скорее.');
         } else {
             Yii::$app->session->setFlash('error', 'Ошибка отправки электронной почты.');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 21
0
 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', "Дякую, що написали нам. Ми зв'яжимось з вами.");
         } else {
             Yii::$app->session->setFlash('error', 'Виникла помилка при відправці листа. Будь ласка спробуйте пізніше');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 22
0
 /**
  * Displays contact page.
  *
  * @return mixed
  */
 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', '感谢你联系我们。我们将尽快回复你。');
         } else {
             Yii::$app->session->setFlash('error', '发送的电子邮件有一个错误。');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 23
0
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->getRequest()->getBodyParams(), '') && $model->validate()) {
         if (true) {
             $response = ['flash' => ['class' => 'success', 'message' => 'Thank you for contacting us. We will respond to you as soon as possible.']];
         } else {
             $response = ['flash' => ['class' => 'error', 'message' => 'There was an error sending email.']];
         }
         return $response;
     } else {
         $model->validate();
         return $model;
     }
 }
Exemplo n.º 24
0
 /**
  * Displays contact page.
  *
  * @return mixed
  */
 public function actionContact()
 {
     $this->pageDescription = 'Если у вас есть деловое предложение или другие вопросы, пожалуйста, заполните форму на странице, чтобы связаться с нами.';
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail(Yii::$app->params['infoEmail'])) {
             Yii::$app->session->setFlash('success', 'Ваше сообщение было отправлено.<br/> Наши сотрудники в кратчайшее время свяжуться с Вами по электронной почте, которая была указана в форме. Благодарим Вас за обращение к нам.');
         } else {
             Yii::$app->session->setFlash('error', 'Oшибка отправки электронной почты.');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 25
0
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail()) {
             Yii::$app->getSession()->setFlash('success', ['type' => 'success', 'duration' => 5000, 'icon' => 'glyphicon glyphicon-envelope', 'message' => 'Muchas gracias por contactarnos. Le responderemos a la brevedad', 'title' => 'Contacto', 'positonY' => 'top', 'positonX' => 'center']);
             return $this->goHome();
         } else {
             Yii::$app->getSession()->setFlash('danger', ['type' => 'danger', 'duration' => 5000, 'icon' => 'glyphicon glyphicon-exclamation-sign', 'message' => 'Ocurrió un error al enviar el mail. Por favor, comuníquese con info@remisesramallo.com.ar', 'title' => 'Contacto', 'positonY' => 'top', 'positonX' => 'center']);
             return $this->goHome();
         }
     } else {
         return $this->renderAjax('contact', ['model' => $model]);
     }
 }
 /**
  * Test contact.
  */
 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);
     });
 }
Exemplo n.º 27
0
 public function actionContact()
 {
     $this->layout = 'inner';
     $model = new ContactForm();
     if (Yii::$app->request->isAjax && $model->load(\Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $body = " <div>Body: <b> " . $model->body . " </b></div>";
         $body .= " <div>Email: <b> " . $model->email . " </b></div>";
         Yii::$app->common->sendMail($model->subject, $body);
         print 'Send success';
         die;
     }
     return $this->render('contact', ['model' => $model]);
 }
Exemplo n.º 28
0
 public function actionContact()
 {
     $session = Yii::$app->session;
     $session->remove('category');
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
             Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
         } else {
             Yii::$app->session->setFlash('error', 'There was an error sending email.');
         }
         return $this->refresh();
     } else {
         $data = Config::find()->select('content, title, description, keyword')->where('com="contact"')->one();
         return $this->render('contact', ['model' => $model, 'data' => $data]);
     }
 }
Exemplo n.º 29
0
 /**
  * Contact Us page render
  *
  * @param $page
  * @return string
  * @throws Mandrill_Error
  * @throws \Exception
  */
 private function renderContactUs($page)
 {
     $model = new ContactForm();
     $mess = '';
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $settings = new Settings();
         /** @var string $sendTo - address which collects feedback from customers
          *  @fixme change this emails
          */
         try {
             $support = $settings->getConfigurationParamByKey('support_email');
         } catch (\yii\base\Exception $e) {
             $support = null;
         }
         try {
             $support = $settings->getConfigurationParamByKey('admin_email');
         } catch (\yii\base\Exception $e) {
             $admin = null;
         }
         if (!$support) {
             $sendTo = \Yii::$app->params['supportEmail'];
         } else {
             $sendTo = $support;
         }
         if (!$admin) {
             $replyTo = \Yii::$app->params['adminEmail'];
         } else {
             $replyTo = $admin;
         }
         $name = Yii::$app->request->post("ContactForm")['name'];
         $body = Yii::$app->request->post("ContactForm")['body'];
         $usermail = Yii::$app->request->post("ContactForm")['email'];
         $subject_internal = Yii::$app->request->post("ContactForm")['subject'];
         $subject = "New Feedback from {$name} ({$usermail})";
         $mailer = new \common\helpers\Mandrill($sendTo, $subject, $local_tpl_name = null, $sender = null, ['from_name' => '[Auto-generated]', 'reply_to' => $replyTo, 'mandrill_template_name' => 'contactrazzd', 'vars' => ['header' => $subject_internal, 'body' => $body, 'usermail' => $usermail]]);
         $result = $mailer->sendWithMandrillTemplate();
         $mess = (string) $result;
         if ($result) {
             Yii::$app->session->setFlash('success', 'Your message has been sent.');
         } else {
             Yii::$app->session->setFlash('error', 'Is there something wrong. Contact Support.');
         }
         $model = new ContactForm();
     }
     return $this->render('contact_us', ['page' => $page, 'model' => $model]);
 }
Exemplo n.º 30
-1
 /**
  * Displays contact page.
  *
  * @return mixed
  */
 public function actionContact()
 {
     require_once '../vendor/smtpmail/PHPMailer.php';
     $model = new ContactForm();
     $mail = new PHPMailer();
     $mail->Mailer = "smtp";
     $mail->IsHTML(true);
     $mail->SMTPSecure = "tls";
     $mail->Host = "smtp.gmail.com";
     $mail->Port = 587;
     $mail->SMTPAuth = true;
     $mail->IsSMTP();
     $mail->Username = "******";
     // Your Email Address
     $mail->Password = "******";
     // Your Password
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $mail->SetFrom($model->email, $model->name);
         $mail->FromName = "CITLLEIRIA";
         $mail->Subject = $model->subject;
         $msg = $model->body . '<br />' . $model->name;
         $mail->MsgHtml($msg);
         $mail->CharSet = "UTF-8";
         $mail->AddAddress($model->email, $model->name);
         if ($model->sendEmail(Yii::$app->params['Username'])) {
             Yii::$app->session->setFlash('success', 'Mail Enviado');
         } else {
             Yii::$app->session->setFlash('error', 'There was an error sending email.');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }