sendEmail() public method

Sends an email to the specified email address using the information collected by this model.
public sendEmail ( string $email ) : boolean
$email string the target email address
return boolean whether the email was sent
Exemplo n.º 1
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.º 2
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()) {
         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.º 4
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.º 5
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.º 6
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.º 7
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]);
     }
 }
 public function actionIndex()
 {
     $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->render('/order/thank');
     } else {
         return $this->render('index', ['model' => $model]);
     }
 }
Exemplo n.º 9
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.º 10
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.º 11
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.º 12
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.º 13
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.º 14
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->addFlash('success', Yii::t('frontend', 'Thank you for contacting us. We will respond to you as soon as possible.'));
         } else {
             Yii::$app->session->addFlash('error', Yii::t('frontend', 'There was an error sending 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
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail('*****@*****.**')) {
             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 {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 17
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.º 18
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]);
     }
 }
Exemplo n.º 19
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.º 20
0
 public function actionContact()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->getRequest()->getBodyParams(), '') && $model->validate()) {
         if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
             $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;
     }
 }
 /**
  * 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.º 22
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.º 23
0
 public function actionContact()
 {
     $model = new ContactForm();
     //ajax request
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         Yii::$app->response->format = 'json';
         if ($model->load(Yii::$app->request->post()) && $model->validate()) {
             if ($model->sendEmail(Yii::$app->params['contactEmail'])) {
                 return ['message' => Yii::t('app', 'Thank you. We will respond to you as soon as possible.'), 'status' => 'success'];
             } else {
                 return ['message' => Yii::t('app', 'There was an error sending email.'), 'status' => 'error'];
             }
         } else {
             return ['message' => Yii::t('app', 'There was an error during processing your inputs.'), 'status' => 'error'];
         }
         //otherwise show form
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
 /**
  * Displays a single FLanguecenter model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id, $slug = null)
 {
     $this->layout = '@frontend/views/layouts/layout-frontend.php';
     $langue = $this->findModel($id);
     if ($slug != $langue->slug) {
         return $this->redirect(['languecenter/view', 'id' => $id, 'slug' => $langue->slug]);
     }
     $langue->number++;
     $langue->save();
     $contact = new ContactForm();
     $rate = new FRateCenter();
     $rate->value = round($langue->rate);
     if ($contact->load(Yii::$app->request->post()) && $contact->validate()) {
         if ($contact->sendEmail($langue->email)) {
             Yii::$app->session->setFlash('success-email', Yii::t('frontend', 'Thank you for contacting us. We will respond to you as soon as possible.'));
         } else {
             Yii::$app->session->setFlash('error-email', Yii::t('frontend', 'There was an error sending email.'));
         }
         // die('hello1');
         return $this->refresh();
     }
     return $this->render('view', ['rate' => $rate, 'model' => $langue, 'contact' => $contact]);
 }
Exemplo n.º 25
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('app', 'CONTACT_SUCCESS_SEND'));
         } else {
             Yii::$app->session->setFlash('error', Yii::t('app', 'CONTACT_ERROR_SEND'));
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 26
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', 'Gracias por contactarnos. Le responderemos lo más pronto posible.');
         } else {
             Yii::$app->session->setFlash('error', 'Se produjo un error al enviar el e-mail');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 27
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', 'Gracias por contactarnos');
         } else {
             Yii::$app->session->setFlash('error', 'Ups! Hubo un error');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 28
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', 'Gracias por Contacterse. Nosotros le responderemos lo más rapido posible.');
         } else {
             Yii::$app->session->setFlash('error', 'No se pudo enviar el Comentario, Intentelo de nuevo.');
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 29
0
 /**
  * Displays contact page.
  *
  * @return mixed
  */
 public function actionContact()
 {
     $this->thisPage = 'contact';
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
             Yii::$app->session->setFlash('success', Lang::t('page/contact', 'sendSuccess'));
         } else {
             Yii::$app->session->setFlash('error', Lang::t('page/contact', 'sendError'));
         }
         return $this->refresh();
     } else {
         return $this->render('contact', ['model' => $model]);
     }
 }
Exemplo n.º 30
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]);
     }
 }