public function actionReport()
 {
     $model = new ReportForm();
     if (isset($_POST['ReportForm'])) {
         $model->attributes = $_POST['ReportForm'];
         if ($model->validate()) {
             if (!$model->email) {
                 $model->email = 'nobody@localhost';
             }
             if (!$model->name) {
                 $model->name = 'Anonymous';
             }
             $model->report = 'Sent through: ' . Yii::app()->request->getBaseUrl(true) . "\n\n" . $model->report;
             $message = new YiiMailMessage();
             $message->setTo(Yii::app()->params['admin_email']);
             $message->setFrom(array($model->email => $model->name));
             $message->setSubject(Yii::t('mc', 'Support Form'));
             $message->setBody($model->report);
             Yii::app()->mail->send($message);
             Yii::app()->user->setFlash('report', Yii::t('mc', 'Thank you for contacting us!'));
             Yii::log('Support form submitted');
             $this->refresh();
         }
     }
     $this->render('report', array('model' => $model));
 }
 public function actionCompleteRegistrationAjax()
 {
     $client = new Client();
     $client->attributes = $_POST['Client'];
     if ($client->save()) {
         $drive = new Drive();
         $drive->attributes = $_POST['Drive'];
         $drive->client_id = $client->primaryKey;
         $drive->creation_date = date("Y-m-d H:i:s");
         if ($drive->save()) {
             $driv = Drive::model()->findByPk($drive->primaryKey);
             $message = new YiiMailMessage();
             $message->view = 'pruebamanejo';
             $message->setBody(array("client" => $client, "drive" => $driv), 'text/html');
             $message->setSubject('Solicitud Prueba de Manejo');
             foreach ($driv->concessioner->emails as $email) {
                 // if($email->type=="DRIVE"){
                 if ($email->type == "QUOTATION") {
                     $message->addTo($email->description);
                 }
             }
             //          		$message->addTo("*****@*****.**");
             //				$message->addTo("*****@*****.**");
             $message->addTo("*****@*****.**");
             $message->addTo("*****@*****.**");
             $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador'));
             Yii::app()->mail->send($message);
             echo json_encode(true);
         } else {
             echo json_encode(false);
         }
     }
 }
 public function actionSatisfaction($id)
 {
     $suggestion = Suggestion::model()->findByPk($id);
     $model = new SatisfactionS();
     if (isset($_POST['SatisfactionS'])) {
         $model->attributes = $_POST['SatisfactionS'];
         $model->suggestion_id = $suggestion->id;
         if ($model->save()) {
             $sat = SatisfactionS::model()->findByPk($model->primaryKey);
             $message = new YiiMailMessage();
             $message->view = 'encuesta_s';
             $message->setBody(array("satisfaction" => $sat), 'text/html');
             $message->setSubject('Satisfacción del Prospecto Web.');
             if ($sat->score < 10) {
                 $message->setSubject('Satisfacción del Prospecto Web.');
             }
             if ($sat->contact == "NO") {
                 $message->setSubject('Prospecto No Contactado');
             }
             $aux1 = strstr($suggestion->type, '-');
             $aux = substr($aux1, 1, 1);
             foreach ($suggestion->concessioner->emails as $email) {
                 if ($email->type == "SUGGESTION-{$aux}") {
                     $message->addTo($email->description);
                     // $message->addTo('*****@*****.**');
                     if ($email->type == "SUGGESTION-O") {
                         $message->addTo("*****@*****.**");
                     }
                     $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador'));
                 }
             }
             //$message->addTo("*****@*****.**");
             $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador'));
             Yii::app()->mail->send($message);
             $this->render('satisfaction_finished', array('suggestion' => $suggestion));
         }
     } else {
         if ($suggestion) {
             $this->render('satisfaction', array('model' => $model, 'suggestion' => $suggestion));
         }
     }
 }
Exemple #4
0
 public function sendEmail()
 {
     $this->checkEmailConditions();
     Yii::import('application.extensions.yii-mail.YiiMailMessage');
     $message = new YiiMailMessage();
     $message->setSubject($this->emailSubject);
     $message->view = $this->emailViewFile;
     $message->setBody($this->emailParams, 'text/html');
     $message->setTo($this->receiverEmail);
     $message->from = $this->senderEmail;
     return Yii::app()->mail->send($message);
 }
 /**
  * Send notification for user, that has sent message for administration
  * @return mixed
  */
 public function sendSenderNotification()
 {
     $this->checkNotificationCondition();
     Yii::import('application.extensions.yii-mail.YiiMailMessage');
     $senderNotification = new YiiMailMessage();
     $senderNotification->setSubject($this->notificationSubject);
     $senderNotification->view = $this->notificationViewFile;
     $senderNotification->setBody($this->notificationParams, 'text/html');
     $senderNotification->setTo($this->notificationReceiver);
     $senderNotification->from = $this->notificationSender;
     return Yii::app()->mail->send($senderNotification);
 }
Exemple #6
0
 public function actionRubric($id = null)
 {
     if ($_POST['Form']) {
         $model = new Form('new');
         $this->performAjaxValidation($model);
         $model->attributes = $_POST['Form'];
         $model->date = time();
         if ($_FILES['file']['tmp_name']) {
             $file = CUploadedFile::getInstanceByName('file');
             $model->file = $file->getName();
         }
         if ($model->save()) {
             $text = 'Имя: ' . $model->name;
             $text .= '<br />Фамилия: ' . $model->lastname;
             $text .= '<br />E-mail: ' . $model->email;
             $text .= '<br />Телефон: ' . $model->tel;
             if ($model->arts) {
                 $text .= '<br />Артикулы под нанесение: ' . $model->arts;
             }
             if ($model->delivered) {
                 $text .= '<br />Желаемая дата заказа: ' . $model->delivered;
             }
             $text .= '<br />Кол-во цветов: ' . $model->color;
             $text .= '<br />Тираж: ' . $model->tirazh;
             $text .= '<br />Размеры: ' . $model->width . ' x ' . $model->height;
             $text .= '<br />Драг.металы:';
             $text .= '<br />Золото - ' . ($model->gold ? 'Да' : 'Нет');
             $text .= '<br />Платина - ' . ($model->platina ? 'Да' : 'Нет');
             if ($model->text) {
                 $text .= '<br />Примечание: ' . $model->text;
             }
             $message = new YiiMailMessage();
             $message->setTo(array($this->getConfig('email3') => 'Комплекс Бар'));
             $message->setFrom(array($model->email => $model->name . ' ' . $model->lastname));
             $message->setSubject('Заказ на нанесение');
             $message->setBody($text, 'text/html', 'utf8');
             if ($_FILES['file']['tmp_name']) {
                 $fileNewPath = $_SERVER['DOCUMENT_ROOT'] . '/userdata/nanesenie/' . $file->getName();
                 $file->saveAs($fileNewPath);
                 $message->attach(Swift_Attachment::fromPath($fileNewPath));
             }
             Yii::app()->mail->send($message);
             Yii::app()->user->setFlash('message', 'Спасибо за заказ. Наш менеджер свяжется с вами в ближайшее время.');
         } else {
             $this->render('rubric', $data);
         }
         $this->refresh();
     }
     $rubric = Rubrics::model()->findByPk($id);
     $data = array('rubric' => $rubric);
     $this->render('rubric', $data);
 }
 public function actionMailTes()
 {
     $message = new YiiMailMessage();
     $message->setBody('tes', 'text/html');
     $message->setTo('*****@*****.**');
     $message->setSubject('tes');
     $message->setFrom('*****@*****.**');
     $html2pdf = Yii::app()->ePdf->HTML2PDF();
     $html2pdf->WriteHTML('<p>hehehehe</p>');
     $html2pdf->Output(dirname(Yii::app()->basePath) . '/pdf/tes.pdf', EYiiPdf::OUTPUT_TO_FILE);
     $message->attach(Swift_Attachment::frompath(dirname(Yii::app()->basePath) . '/pdf/tes.pdf'));
     Yii::app()->mail->send($message);
     CVarDumper::dump(YiiMail::log($message), 10, true);
 }
Exemple #8
0
 public static function send($to, $subject, $view, $params)
 {
     $message = new YiiMailMessage();
     $message->view = $view;
     $message->setSubject($subject);
     $message->setBody($params, 'text/html');
     $message->getHeaders()->addMailboxHeader('Sender');
     $message->setSender(Yii::app()->mail->transportOptions['username']);
     $message->addTo($to);
     $message->from = Yii::app()->mail->transportOptions['username'];
     try {
         return Yii::app()->mail->send($message);
     } catch (Exception $e) {
         return false;
     }
 }
 public function sendEmail()
 {
     $this->checkEmailConditions();
     Yii::import('application.extensions.yii-mail.YiiMailMessage');
     $message = new YiiMailMessage();
     $message->setSubject($this->subject);
     $message->view = 'mass-delivery';
     $message->setBody(array('text' => $this->text), 'text/html');
     $message->from = Yii::app()->params['emails']['defaultSender'];
     if (is_array($this->receiverEmail)) {
         foreach ($this->receiverEmail as $email) {
             $message->setTo($email);
             Yii::app()->mail->send($message);
         }
     }
     return TRUE;
 }
 public function save()
 {
     /** @var $user User */
     $user = User::model()->findByAttributes(array('email' => $this->email));
     if ($user) {
         $newPassword = substr(md5(rand(1, 100)), 0, 8);
         $user->changePassword($newPassword);
         $user->save();
         Yii::import('application.extensions.yii-mail.YiiMailMessage');
         $message = new YiiMailMessage();
         $message->setSubject('Відновлення паролю на сайті РЕЗИДЕНТ');
         $message->view = 'restore-password';
         $message->setBody(array('name' => $user->getFirstName(), 'password' => $newPassword), 'text/html');
         $message->setTo($this->email);
         $message->from = Yii::app()->params['emails']['defaultSender'];
         Yii::app()->mail->send($message);
     }
 }
 public function recoverPassword()
 {
     $u = User::model()->findByAttributes(array('username' => $this->username));
     $newPassword = substr(md5(uniqid()), 0, 6);
     $u->password = $newPassword;
     $u->save();
     $body = "Hello " . $u->first_name . ' ' . $u->last_name . ",\n\nYour login details are:\n\n";
     $body .= "Username: "******"\n";
     $body .= "Password: "******"\n";
     $body .= "\n\nPromocast Team";
     $message = new YiiMailMessage();
     $message->setTo(array($u->email => $u->first_name . ' ' . $u->last_name));
     $message->setFrom(array('*****@*****.**' => 'Promocast'));
     $message->setSubject('Your password');
     $message->setBody($body);
     $numsent = Yii::app()->mail->send($message);
     return true;
 }
 public function actionComment()
 {
     if (!isset($_GET['id'])) {
         throw new CHttpException(500, "Ломаешь?");
     }
     /**
      * @var $model SupportTickets
      */
     $model = SupportTickets::model()->findByPk($_GET['id']);
     if (!$model) {
         throw new CHttpException(404, "Не найдено");
     }
     if (Yii::app()->request->isPostRequest) {
         if (isset($_POST['content']) && isset($_POST['toClose'])) {
             if ($_POST['toClose'] == 1) {
                 $model->status = 2;
             } else {
                 $model->status = 1;
             }
             $model->save();
             $m2 = new SupportTicketsComments();
             $m2->ticketId = $model->id;
             $m2->userId = Yii::app()->user->id;
             $m2->datePosted = time();
             $m2->isAnswer = 1;
             $m2->content = $_POST['content'];
             $m2->save();
             Yii::import('ext.yii-mail.*');
             $message = new YiiMailMessage();
             $message->view = 'supportNewReply';
             $message->setSubject('Тикет #' . $model->id . " - Новый ответ");
             $message->setBody(array('model' => $model), 'text/html');
             $message->setTo($model->user->email);
             $message->from = array(Yii::app()->params['adminEmail'] => 'Crystal Reality Games');
             Yii::app()->mail->send($message);
             $this->redirect($this->createUrl("index"));
         } else {
             $this->redirect($this->createUrl("view", ["id" => $model->id]));
         }
     }
 }
Exemple #13
0
 /**
  * 
  * Generic Mail sender method send the generic perfony html mail  
  * @param array $params
  * contains any param passed on to the generic view file
  *
  *  basePath : absolute server path
  *  imgPath : absolute path to images folder
  *  subject : ovious
  *  email : message mail will be send to
  *  sectionTitle : message Section tilte
  *  title : message title
  *  genericText : information text at the top 
  *  view : defaults to 'contact' but could be different 
  *  body : is the main body of the message 
  *  link : appended to the message for direct access to the subject
  *  placeholders : key/value array to use to find/replace in body
  *  
  * @param string $view : name of the view to be used a base
  */
 public static function mail($params)
 {
     $k_path_url = (isset($_SERVER['HTTPS']) and !empty($_SERVER['HTTPS']) and strtolower($_SERVER['HTTPS']) != 'off') ? 'https://' : 'http://';
     $params['basePath'] = $k_path_url . $_SERVER['SERVER_NAME'] . substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], "/") + 1);
     $params['imgPath'] = $params['basePath'] . 'images/email';
     $yiimail = new YiiMailMessage();
     if (!isset($params['subject'])) {
         $params['subject'] = Yii::t('mail', 'subject' . $params['key']);
     }
     $yiimail->setSubject($params['subject']);
     $yiimail->setTo(array($params['email']));
     $yiimail->setFrom(array(Yii::app()->params['adminEmail']));
     if (!isset($params['sectionTitle'])) {
         $params['sectionTitle'] = Yii::t('mail', 'sectionTitle' . $params['key']);
     }
     if (!isset($params['title'])) {
         $params['title'] = Yii::t('mail', 'title' . $params['key']);
     }
     if (!isset($params['genericText'])) {
         $params['genericText'] = Yii::t('mail', 'genericText' . $params['key']);
     }
     $yiimail->view = isset($params['view']) ? $params['view'] : 'contact';
     if (!isset($params['body'])) {
         $params['body'] = Yii::t('mail', 'body' . $params['key']);
     }
     if (isset($params['link'])) {
         $params['body'] .= "<br/><a href='" . Yii::app()->createAbsoluteUrl("/" . $params['link']) . "'>" . Yii::t(PTranslate::CAT_MAILS, 'Direct Link to access') . "</a>";
     }
     if (isset($params['placeholders'])) {
         foreach ($params['placeholders'] as $key => $val) {
             //throw new CHttpException('pouet avant : '.$params['placeholders'].' après : '.str_replace($key, $val, $params['placeholders']));
             $params['body'] = str_replace($key, $val, $params['body']);
         }
     }
     $yiimail->setBody($params, 'text/html');
     if (Yii::app()->params['sendMails']) {
         Yii::app()->mail->send($yiimail);
     }
 }
 public function actionCreateAjax($ccmp_id)
 {
     if (isset($_POST['User'])) {
         //$this->performAjaxValidation($model4update, 'branch-form');
         try {
             $user = new User();
             $user->username = $_POST['User']['username'];
             $user->email = $_POST['User']['email'];
             $user->superuser = 0;
             $user->status = 1;
             $profile = new Profile();
             $profile->attributes = $_POST['Profile'];
             if (!$user->validate() || !$profile->validate()) {
                 $this->renderPartial("/Customers/_form_horizontal_ajax", array('ccmp_id' => $ccmp_id, 'model4updateuser' => $user, 'model4updateprofile' => $profile));
                 exit;
             }
             $pass = CcmpCompany::createCustomerUser($user, $profile, $ccmp_id);
             $yiiuser = Yii::app()->getComponent('user');
             $yiiuser->setFlash('success', "Customer user created with password " . $pass);
             if (isset($_POST['email_pass'])) {
                 $message = new YiiMailMessage();
                 $message->setSubject('New user created');
                 $message->setBody('New user created. <br />
                                username: <b>' . $user->username . '</b>, password:<b> ' . $pass . '</b>', 'text/html');
                 $message->addTo($_POST['email_pass']);
                 $message->from = '*****@*****.**';
                 $sent = Yii::app()->mail->send($message);
             }
         } catch (Exception $e) {
             $this->renderPartial("/Customers/_form_horizontal_ajax", array('ccmp_id' => $ccmp_id, 'model4updateuser' => $user, 'model4updateprofile' => $profile));
             exit;
         }
     }
     $model4newuser = new User();
     $model4newprofile = new Profile();
     $this->renderPartial("/Customers/_form_horizontal_ajax", array('ccmp_id' => $ccmp_id, 'model4updateuser' => $model4newuser, 'model4updateprofile' => $model4newprofile));
     //$this->render('view', array('model' => $model, 'model4grid' => $model4grid, 'model4update' => $model4update));
 }
 protected function registerUser()
 {
     $model = new User();
     $model->first_name = $this->name;
     $model->password = $this->password;
     $model->email = $this->email;
     $model->sex = $this->sex;
     $model->role = WebUser::ROLE_USER;
     if ($model->save(FALSE)) {
         Yii::import('application.extensions.yii-mail.YiiMailMessage');
         $message = new YiiMailMessage();
         $message->setSubject('Вітаємо на сайті РЕЗИДЕНТ');
         $message->view = 'registration-notification';
         $message->setBody(array('name' => $this->name, 'password' => $this->password), 'text/html');
         $message->setTo($this->email);
         $message->from = Yii::app()->params['emails']['defaultSender'];
         Yii::app()->mail->send($message);
         $this->_userModel = $model;
         return TRUE;
     } else {
         return FALSE;
     }
 }
Exemple #16
0
 public function sendMailWithTemplate($email = NULL, $subject = NULL, $view = NULL, $data = NULL, $serverMail = '*****@*****.**', $layout = 'layout', $from = NULL)
 {
     if (isset($email) && isset($view)) {
         /**
          * @todo Change message email
          */
         $subject = isset($subject) ? $subject : "(No Subject)";
         try {
             $message = new YiiMailMessage();
             $message->view = $layout;
             $message->setSubject($subject);
             $message->setBody(array('data' => isset($data) ? $data : array(), 'serverMail' => $serverMail, 'view' => $view), 'text/html');
             $message->addTo($email);
             $from = '*****@*****.**';
             // $message->from = $from;
             $message->from = array($from => "VDC TrainingLab");
             Yii::app()->mail->send($message);
             return array('error' => false, 'data' => $message);
         } catch (Exception $ex) {
             // TODO : Can't send mail
             return array('error' => true, 'message' => $ex->getMessage());
         }
     }
 }
 public function actionDiagnostic()
 {
     $medio = "default";
     if (isset($_GET["medio"])) {
         $medio = $_GET["medio"];
     }
     $client = new Client();
     $vehicle = new VehicleClient();
     $replacement = new Replacement();
     $criteria2 = new CDbCriteria();
     //$criteria2->condition = 'id = 1 OR id = 2 OR id = 9 OR id = 10 OR id = 11  OR id = 13 OR id = 14 OR id= 15 OR id = 16';
     $concessioners = Concessioner::model()->findAllbyAttributes(array(), $criteria2);
     $criteria = new CDbCriteria();
     //$criteria->condition = 'id != 36';
     $criteria->order = 'name';
     $versions = VehicleVersion::model()->with('vehicle')->findAllbyAttributes(array(), $criteria);
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'replacement-form') {
         echo CActiveForm::validate($client);
         Yii::app()->end();
     }
     if (isset($_POST['siguiente'])) {
         if (isset($_POST['Client']) && isset($_POST['Replacement']) && isset($_POST['VehicleClient'])) {
             $client = new Client();
             $client->attributes = $_POST['Client'];
             $client->save();
             $vehicle = new VehicleClient();
             $vehicle->attributes = $_POST['VehicleClient'];
             //die(print_r($vehicle->attributes));
             $vehicle->kilometer = "1";
             $vehicle->save();
             $replacement = new Replacement();
             $replacement->attributes = $_POST['Replacement'];
             $replacement->client_id = $client->primaryKey;
             $replacement->vehicle_id = $vehicle->primaryKey;
             if ($replacement->save()) {
                 $rep = Replacement::model()->findByPk($replacement->primaryKey);
                 $message = new YiiMailMessage();
                 $message->view = 'repuesto';
                 $message->setBody(array("replacement" => $rep), 'text/html');
                 $message->setSubject('Prospecto para repuesto');
                 foreach ($rep->concessioner->emails as $email) {
                     if ($email->type == "REPLACEMENT") {
                         $message->addTo($email->description);
                     }
                 }
                 $message->addTo("*****@*****.**");
                 $message->addTo("*****@*****.**");
                 $message->addTo("*****@*****.**");
                 $message->addTo("*****@*****.**");
                 $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador'));
                 Yii::app()->mail->send($message);
                 $this->render('result', array("client" => $client, "vehicle" => $vehicle, "replacement" => $replacement));
             } else {
                 $this->render('error');
             }
         }
         //$this->render('index',array('concessioners'=>$concessioners,"client"=>$client,"vehicle"=>$vehicle,"replacement"=>$replacement));
     } else {
         $this->render('index_d', array('concessioners' => $concessioners, "client" => $client, "vehicle" => $vehicle, "replacement" => $replacement, "versions" => $versions, "medio" => $medio));
     }
 }
 /**
  * Displays the contact page
  */
 public function actionContact()
 {
     $model = new ContactForm();
     if (isset($_POST['ContactForm'])) {
         // main contact form
         $model->attributes = $_POST['ContactForm'];
         if ($model->validate()) {
             $name = '=?UTF-8?B?' . base64_encode($model->name) . '?=';
             $subject = '=?UTF-8?B?' . base64_encode($model->subject) . '?=';
             $headers = "From: {$name} <{$model->email}>\r\n" . "Reply-To: {$model->email}\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/plain; charset=UTF-8";
             mail('LinxCircle Contact <*****@*****.**>', $subject, $model->body, $headers);
             Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
             $this->refresh();
         }
     } else {
         if (isset($_POST['ContactableForm'])) {
             // jquery widget
             // Assign contact info
             $name = stripcslashes($_POST['name']);
             $emailAddr = stripcslashes($_POST['email']);
             $issue = stripcslashes($_POST['issue']);
             $comment = stripcslashes($_POST['message']);
             $subject = stripcslashes($_POST['subject']);
             //$name='=?UTF-8?B?'.base64_encode($name).'?=';
             $subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
             // Format message
             $contactMessage = "<div>\n\t\t\t<p><strong>Name:</strong> {$name} <br />\n\t\t\t<strong>E-mail:</strong> {$emailAddr} <br />\n\t\t\t<strong>Issue:</strong> {$issue} </p>\n\t\t\t\t\n\t\t\t<p><strong>Message:</strong> {$comment} </p>\n\t\t\t\t\n\t\t\t<p><strong>Sending IP:</strong> {$_SERVER['REMOTE_ADDR']}<br />\n\t\t\t<strong>Sent via:</strong> {$_SERVER['HTTP_HOST']}</p>\n\t\t\t</div>";
             // Send and check the message status
             $message = new YiiMailMessage();
             $message->setBody($contactMessage, 'text/html');
             $message->setSubject($subject);
             $message->setTo(array('*****@*****.**' => 'LinxCircle Contact'));
             $message->setFrom(array($emailAddr => $name . " (LinxCircle)"));
             $message->setReplyTo(array($emailAddr => $name . " (LinxCircle)"));
             $result = Yii::app()->mail->send($message);
             $response = $result ? "success" : "failure";
             $output = json_encode(array("response" => $response, "result" => $result));
             header('content-type: application/json; charset=utf-8');
             echo $output;
             return;
         }
     }
     $this->render('contact', array('model' => $model));
 }
Exemple #19
0
 public function sendEmail($emails, $subject, $message)
 {
     if ($this->getHost() == null) {
         return;
     }
     /**
      * @var $mailer YiiMail
      */
     $mailer = Yii::createComponent(array('class' => 'YiiMail', 'transportType' => $this->getMailMethod(), 'transportOptions' => array('host' => $this->getHost()), 'logging' => false));
     $mailerTransport = $mailer->getTransport();
     if ($this->getAuthUser() !== null) {
         //нужна авторизация на сервере
         $mailerTransport->setUsername(trim($this->getAuthUser()))->setPassword(trim($this->getAuthPassword()));
     } else {
         $mailerTransport->setUsername(null)->setPassword(null);
     }
     $mailMessage = new YiiMailMessage();
     $mailMessage->setBody($message, 'text/plain', 'utf-8');
     $mailMessage->setFrom($this->getSentFrom());
     $mailMessage->setSubject($subject);
     $mailMessage->setTo($emails);
     $errorMessage = false;
     try {
         if (!$mailer->send($mailMessage, $failures)) {
             $errorMessage = sprintf("Ошибка при отправке почты:\n %s", print_r($failures, true));
         }
     } catch (Exception $e) {
         $errorMessage = $e->getMessage();
     }
     if ($errorMessage) {
         $this->log($errorMessage);
     }
 }
 public function save($runValidation = true, $attributes = null)
 {
     // check if account_email is associated with any account at all
     $account = Account::model()->getAccountByEmail($this->account_email);
     if ($account == null) {
         $this->addError('account_email', 'This email is not associated with any account.');
         return false;
     }
     // create record
     if ($this->isNewRecord) {
         $this->account_id = $account->account_id;
         $this->account_password_reset_rand_key = $this->generateRandomKey($account->account_created_date);
         $this->account_password_reset_rand_key_expiry = $this->getExpiryDate();
     }
     $result = parent::save($runValidation, $attributes);
     if ($result) {
         // email customer step to reset password
         $message = new YiiMailMessage();
         $message->view = "passwordResetEmail";
         //userModel is passed to the view
         $message->setBody(array('reset_url' => $this->generateResetURL()), 'text/html');
         $message->setSubject("[" . Yii::app()->name . "] Password Reset");
         $message->addTo($this->account_email);
         $message->setFrom(array(Yii::app()->params['adminEmail'] => 'Admin (LinxCircle)'));
         Yii::app()->mail->send($message);
     }
     return $result;
 }
Exemple #21
0
/**
 * Send email to an address
 *
 * @param string $email receiver's address
 * @param string $view path to view used by mailer (Yii's alias format)
 * @param array $data associative array passed to view
 */
function quickMail($email, $view, $data, $subject = 'Flexicore Member Registration Confirmation')
{
    Yii::import('Core.extensions.vendors.mail.YiiMailMessage');
    $viewName = end(explode('.', $view));
    Yii::app()->mail->viewPath = str_replace('.' . $viewName, '', $view);
    //send mail
    $message = new YiiMailMessage();
    $message->view = $viewName;
    $message->setSubject($subject);
    $message->setBody($data, 'text/html');
    $message->addTo($email);
    if (hasParam('Settings::ADMIN_EMAIL')) {
        $message->setFrom(array(Settings::ADMIN_EMAIL => Settings::SITE_NAME));
    }
    try {
        Yii::app()->mail->send($message);
    } catch (Exception $ex) {
        FErrorHandler::logError($ex->getMessage());
    }
}
Exemple #22
0
 protected function notifyByMail($error)
 {
     if (YII_DEBUG) {
         return;
     }
     // The SwiftMail lib use SERVER_NAME to generate random ID for some purposes
     if (Yii::app() instanceof CConsoleApplication) {
         $_SERVER['SERVER_NAME'] = 'console';
     }
     if (file_exists(cachePath() . 'Settings.php')) {
         include_once cachePath() . 'Settings.php';
     }
     try {
         $mail = Yii::app()->getComponent('mail');
         $mail->viewPath = 'Xpress.views.mails';
         Yii::import('Xpress.extensions.vendors.mail.YiiMailMessage');
         $message = new YiiMailMessage();
         $message->view = 'error_notification';
         $message->setSubject('Error happens on ' . SETTINGS_SITE_NAME . ' (' . Yii::app()->request->getHostInfo() . ')');
         /**
          * @var CHttpException
          */
         $message->setBody(array('error' => $error));
         if (!empty($this->sendNotificationTo)) {
             foreach (explode(',', $this->sendNotificationTo) as $to) {
                 $message->addTo(trim($to));
             }
         } else {
             foreach (explode(',', SETTINGS_DEV_EMAILS) as $to) {
                 $message->addTo(trim($to));
             }
             $message->addTo(SETTINGS_ADMIN_EMAIL);
         }
         $message->setFrom(SETTINGS_ADMIN_EMAIL);
         $mail->send($message);
     } catch (Exception $ex) {
         throw $ex;
         // well, there is really nothing we can do here !!!
     }
 }
 public function actionTestEmail()
 {
     $message = new YiiMailMessage();
     $message->setSubject('Account Activation');
     $body = '<p>Hi.</p><p>Please activiate your account here: </p>';
     $body .= '<p><a href="">Activate my account now.</a></p>';
     $message->setBody($body, 'text/html');
     $message->addTo("*****@*****.**");
     $message->from = Yii::app()->params['adminEmail'];
     Yii::app()->mail->send($message);
 }
 public function SendMail($mail = array())
 {
     $mailer = new YiiMail();
     $mailer->transportType = 'smtp';
     $mailer->transportOptions = array('host' => Config::model()->getValueByKey('host_sendmail'), 'username' => Config::model()->getValueByKey('username_sendmail'), 'password' => Config::model()->getValueByKey('password_sendmail'), 'port' => Config::model()->getValueByKey('port_sendmail'), 'encryption' => Config::model()->getValueByKey('encryption_sendmail'));
     $message = new YiiMailMessage();
     $message->setFrom(array(Config::model()->getValueByKey('username_sendmail') => Config::model()->getValueByKey('displayname_sendmail')));
     $message->setTo(array($mail['mailto']));
     $message->setReplyTo(array($mail['replyto']));
     $message->setSubject($mail['subject']);
     $message->setBody($mail['body'], 'text/html');
     $mailer->send($message);
 }
Exemple #25
0
 public function sendSuccessfulSignupEmailNotification()
 {
     $message = new YiiMailMessage();
     $activation_key = $this->getActivationKey();
     $activation_url = $this->getActivationURL($activation_key);
     /**
     		$body = '<p>Hello.</p>';
     		$body .= "<p>Welcome to " . Yii::app()->name . "</p>";
     		$body .= '<p>Your registration is successful. In order to start enjoying our amazing stuff, please activate your account by clicking the link below: </p>';
     		$body .= '<p><a href="' . $activation_url . '">Activate my account now.</a></p>';
     		//$body .= '<p>DEBUG: ' . $account->account_email . $account->account_created_date . '</p>';
     		$body .= "<p>" . Yii::app()->params['emailSignature'] . "</p>";
     		**/
     $message->view = "successfulSignupEmail";
     //userModel is passed to the view
     $message->setBody(array('activation_url' => $activation_url), 'text/html');
     $message->setSubject('Account Activation');
     //$message->setBody($body, 'text/html');
     $message->addTo($this->account_email);
     //$message->from = Yii::app()->params['adminEmail'];
     $message->setFrom(array(Yii::app()->params['adminEmail'] => "LinxCircle Admin"));
     Yii::app()->mail->send($message);
 }
Exemple #26
0
 public function actionDoOrder()
 {
     if (Yii::app()->user->isGuest || empty($_POST)) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     $product_ids = Yii::app()->request->getPost('id');
     if (empty($product_ids) || !is_array($product_ids)) {
         throw new CHttpException(404, 'Не выбраны товары для заказа');
     }
     $model_order = new Order();
     if (count($product_ids)) {
         $model_order->order_status_id = Order::STATUS_CREATED;
         $model_order->user_id = Yii::app()->user->id;
         $model_order->ip = $_SERVER['REMOTE_ADDR'];
         $model_order->comment = $_POST['comment'];
         $model_order->date = date('Y-m-d H:i:s', time());
         $model_order->save();
         $order_id = $model_order->order_id;
     }
     $products = array();
     foreach ($product_ids as $pid) {
         if (!isset($_POST["quantity{$pid}"]) || !$_POST["quantity{$pid}"]) {
             continue;
         }
         $model_order_product = new OrderProduct();
         $model_order_product->product_id = $pid;
         $model_order_product->order_id = $order_id;
         $model_order_product->quantity = $_POST["quantity{$pid}"];
         $products[$pid] = $_POST["quantity{$pid}"];
         $model_order_product->save();
     }
     //Отпраляем письмо с заказом
     $message = new YiiMailMessage();
     $message->view = 'orderinfo';
     $message->setSubject("Создан новый заказ на сайте kto-tut.ru");
     $message->setBody(array('products' => $products, 'comment' => $_POST['comment'], 'for_admin' => true), 'text/html');
     $message->addTo(Yii::app()->params['adminEmail']);
     $message->from = Yii::app()->params['adminEmail'];
     Yii::app()->mail->send($message);
     $message = new YiiMailMessage();
     $message->view = 'orderinfo';
     $message->setSubject('Ваш заказ на сайте kto-tut.ru успешно сформирован!');
     $message->setBody(array('products' => $products, 'comment' => $_POST['comment'], 'for_admin' => false), 'text/html');
     $message->addTo(Yii::app()->user->me->email);
     $message->from = Yii::app()->params['adminEmail'];
     Yii::app()->mail->send($message);
     $this->redirect('success');
 }
 public function actionForgot()
 {
     $message = "";
     // TODO: Sanitize input!!!
     if (isset($_POST['email'])) {
         $email = $_POST['email'];
         // TODO: See if user's email address exists in database
         $customer = Customer::model()->findByAttributes(array('bilemail' => $email));
         if ($customer != null) {
             // Send user's password to client
             $message = new YiiMailMessage();
             $message->view = 'template';
             $message->setBody(array('include' => 'forgot-password.php', 'customer' => $customer), 'text/html');
             $message->addTo($customer->bilemail);
             $message->addBcc("*****@*****.**");
             $message->addFrom(Yii::app()->params['adminEmail']);
             $message->setSubject("Password Request");
             Yii::app()->mail->send($message);
             $message = "Email sent.";
         } else {
             $message = "Email address not found.";
         }
     }
     $this->render('forgotpassword', array('message' => $message));
 }
 public function actionCompleteRegistrationAjax()
 {
     $client = new Client();
     $client->attributes = $_POST['Client'];
     if ($client->save()) {
         $quotation = new Quotation();
         $quotation->attributes = $_POST['Quotation'];
         $quotation->client_id = $client->primaryKey;
         $quotation->creation_date = date("Y-m-d H:i:s");
         if ($quotation->save()) {
             $quot = Quotation::model()->findByPk($quotation->primaryKey);
             $message = new YiiMailMessage();
             $message->view = 'cotizador';
             $message->setBody(array("client" => $client, "quotation" => $quot), 'text/html');
             $message->setSubject('Prospecto para Cotización');
             foreach ($quot->concessioner->emails as $email) {
                 if ($email->type == "QUOTATION") {
                     $message->addTo($email->description);
                 }
             }
             // $message->addTo("*****@*****.**");
             //$message->addTo("*****@*****.**");
             //$message->addTo("*****@*****.**");
             $message->addTo("*****@*****.**");
             $message->addTo("*****@*****.**");
             $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador'));
             Yii::app()->mail->send($message);
             echo json_encode(true);
         } else {
             echo json_encode(false);
         }
     }
     // $vehicle_version=  VehicleVersion::model()->findAllByAttributes(array("vehicle_id"=>$_POST['vehicle_id'],"status"=>"ACTIVE"));
     echo json_encode(true);
 }
Exemple #29
0
 /**
  * Sends a message in an extremly simple but less extensive way.
  * 
  * @param mixed from address, string or array of the form $address => $name
  * @param mixed to address, string or array of the form $address => $name
  * @param string subject
  * @param string body
  */
 public function sendSimple($from, $to, $subject, $body)
 {
     $message = new YiiMailMessage();
     $message->setSubject($subject)->setFrom($from)->setTo($to)->setBody($body, 'text/html');
     if ($this->logging === true) {
         self::log($message);
     }
     if ($this->dryRun === true) {
         return count($message->to);
     } else {
         return $this->getMailer()->send($message);
     }
 }
 public function actionTest()
 {
     $message = new YiiMailMessage();
     $message->view = '48hours_repuesto';
     $message->setSubject('¿Cotizamos sus respuestos?');
     $message->setBody(array(), 'text/html');
     $message->addTo("*****@*****.**");
     $message->addTo("*****@*****.**");
     $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador'));
     if (Yii::app()->mail->send($message)) {
         echo "envio 1";
     }
     $message = new YiiMailMessage();
     $message->view = '48hours_sugerencia';
     $message->setSubject('¿Un asesor comercial se ha contactado con usted?');
     $message->setBody(array(), 'text/html');
     $message->addTo("*****@*****.**");
     $message->addTo("*****@*****.**");
     $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador'));
     if (Yii::app()->mail->send($message)) {
         echo "envio 2";
     }
     die("");
 }