Exemplo n.º 1
0
 public function actionRemind()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect('/cabinet/');
     }
     $user = new User('pass');
     $user = User::model()->find('email=:email', array(':email' => $_POST['User']['email']));
     $this->performAjaxValidation($user);
     if (isset($_POST['User'])) {
         $chars = "123456789abcdefghijklmnopqrstuvwxyz";
         $num_chars = strlen($chars);
         $char = $chars[rand(0, $num_chars - 1)];
         for ($i = 1; $i < 6; $i++) {
             $char .= $chars[rand(0, $num_chars - 1)];
         }
         $user->password = $char;
         if ($user->save()) {
             $text = "На ваш E-mail был отправлен запрос восстановления пароля:<br /><br /><b>Ваш новый пароль:</b> " . $char . "<br /><br />Администрация Комплекс Бар.";
             $message = new YiiMailMessage();
             $message->setTo(array($user->email => $user->name . ' ' . $user->lastname));
             $message->setFrom(array('*****@*****.**' => 'Комплекс Бар'));
             $message->setSubject('Новый пароля для сайта Complexbar.ru');
             $message->setBody($text, 'text/html', 'utf8');
             Yii::app()->mail->send($message);
             $this->redirect('/auth/?remind');
         } else {
             exit(var_dump($user->getErrors()));
         }
     }
     $data = array();
     $this->render('/users/auth', $data);
 }
Exemplo n.º 2
0
 public static function sendMail($params = array())
 {
     /** @var $message YiiMailMessage */
     $message = new YiiMailMessage();
     /*
     $base_path = Yii::getPathOfAlias('application.views.mail.images');
     $files = CFileHelper::findFiles($base_path);
     $imgs = array();
     foreach ($files as $file) {
         $imgs[basename($file)] = $message->embed(Swift_Image::fromPath($file));
     }
     if(isset($params['params']['attachedFilePath'], $params['params']['attachedFileName'])) {
         $message->attach(Swift_Attachment::fromPath($params['params']['attachedFilePath'])->setFilename($params['params']['attachedFileName']));
     }
     $params['params']['imgs'] = $imgs;
     */
     $message->view = $params['view'];
     $message->subject = $params['subject'];
     $message->setTo($params['to']);
     if (isset($params['cc'])) {
         $message->setCc($params['cc']);
     }
     if (isset($params['bcc'])) {
         $message->setBcc($params['bcc']);
     }
     $message->setBody($params['params'], 'text/html');
     $message->addPart(self::getPlainTextVersion($message, $params['params']), 'text/plain');
     $message->attachSigner(self::getSigner());
     $message->from = Yii::app()->params['mail_sender'];
     return Yii::app()->mail->send($message);
 }
Exemplo n.º 3
0
 /**
  * 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 9
0
 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);
     }
 }
Exemplo n.º 10
0
 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]));
         }
     }
 }
Exemplo n.º 11
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);
     }
 }
Exemplo n.º 12
0
 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;
     }
 }
Exemplo n.º 13
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);
     }
 }
Exemplo n.º 14
0
 public function send(array $events)
 {
     $eventsCount = count($events);
     if ($eventsCount == 0) {
         return;
     }
     $mailer = Yii::app()->mailer;
     $mailer->init();
     for ($i = 0; $i < $eventsCount; $i++) {
         $curEvent = $events[$i];
         $mailAccount = $curEvent->eventType->mailAccount;
         $mailerTransport = $mailer->getTransport()->setHost($mailAccount->host);
         if ($mailAccount->getIsNeedAuthorize()) {
             //нужна авторизация на сервере
             $mailerTransport->setUsername($mailAccount->user_name)->setPassword($mailAccount->user_password);
         } else {
             $mailerTransport->setUsername(null)->setPassword(null);
         }
         $eventsProcess = $curEvent->getEventsProcess();
         $eventsProcessCount = count($eventsProcess);
         for ($k = 0; $k < $eventsProcessCount; $k++) {
             $curEventProcess = $eventsProcess[$k];
             $mailMessage = new YiiMailMessage();
             $mailMessage->setTo($curEventProcess->email);
             $mailMessage->setSubject($curEvent->subject);
             $messageContent = '';
             if ($curEvent->event_message === null) {
                 $ncEvent = new NotifierComponentEvent($this, $curEvent, $curEventProcess, $mailMessage);
                 $this->onEmptyMessage(new NotifierComponentEvent($this, $curEvent, $curEventProcess, $mailMessage));
                 if ($mailMessage->getBody() == null && empty($ncEvent->params['messageContent'])) {
                     $curEventProcess->saveAsSent();
                     continue;
                 } elseif (!empty($ncEvent->params['messageContent'])) {
                     $messageContent = $ncEvent->params['messageContent'];
                 }
             } else {
                 $messageContent = $curEvent->event_message;
             }
             if ($mailMessage->getFrom() == null) {
                 //если не указан отправитель, то берем из настроек аккаунта
                 if (!empty($mailAccount->from_name)) {
                     $mailMessage->setFrom(array($mailAccount->email_from => $mailAccount->from_name));
                 } else {
                     $mailMessage->setFrom($mailAccount->email_from);
                 }
             }
             //если тема не указана, то в качестве темы устанавливаем название типа события
             if ($mailMessage->getSubject() == null) {
                 $mailMessage->setSubject($curEvent->eventType->name);
             }
             //Если есть что прикреплять
             if (!empty($messageContent)) {
                 $eventFormat = $curEventProcess->eventSubscriber->eventFormat;
                 switch ($eventFormat->place) {
                     case NotifierEventFormat::PLACE_TEXT:
                         $mailMessage->setBody($messageContent, $eventFormat->name == NotifierEventFormat::TYPE_HTML ? 'text/html' : 'text/plain');
                         break;
                     case NotifierEventFormat::PLACE_ATTACHMENT:
                         $fileName = $eventFormat->file_name;
                         if ($curEventProcess->eventSubscriber->getIsArchiveAttachment()) {
                             //TODO Архивируем вложение
                         }
                         //TODO Добавляем файл в аттач
                         break;
                 }
             }
             if (!$this->onBeforeSend(new NotifierComponentEvent($this, $curEvent, $curEventProcess, $mailMessage))) {
                 continue;
             }
             $errorMessage = false;
             try {
                 if ($mailer->send($mailMessage, $failures)) {
                     $curEventProcess->saveAsSent();
                 } else {
                     $errorMessage = sprintf("Ошибка при отправке почты:\n %s", print_r($failures, true));
                 }
             } catch (Exception $e) {
                 $errorMessage = $e->getMessage();
             }
             if ($errorMessage) {
                 Yii::log($errorMessage, CLogger::LEVEL_ERROR, 'mail.notifier.send');
             }
         }
         // endfor $eventProcess
     }
     // endfor $events
 }
 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);
 }
Exemplo n.º 16
0
 public function actionRegistration()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect($this->createUrl("/personal/cabinet/index"));
     }
     $user = new Users();
     if (Yii::app()->request->isPostRequest) {
         if (!isset($_POST['YII_CSRF_TOKEN']) || $_POST['YII_CSRF_TOKEN'] != Yii::app()->getRequest()->getCsrfToken()) {
             throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
         }
         if (!empty($_POST['Reg']['password']) && !empty($_POST['Reg']['password2'])) {
             if ($_POST['Reg']['password'] == $_POST['Reg']['password2']) {
                 $user->setAttributes($_POST['Reg']);
                 if ($user->save()) {
                     Yii::app()->redis->getClient()->set("allUsers_" . $user->username, "needAct");
                     Yii::import('ext.yii-mail.*');
                     $message = new YiiMailMessage();
                     $message->view = 'userActivationLink';
                     $message->setSubject('Активация профиля');
                     $message->setBody(array('user' => $user), 'text/html');
                     $message->setTo($user->email);
                     $message->from = array(Yii::app()->params['adminEmail'] => 'Crystal Reality Games');
                     Yii::app()->mail->send($message);
                     $this->redirect($this->createUrl("/personal/auth/needApprove"));
                 }
             } else {
                 $user->addError("password", "Пароли не совпадают");
             }
         } else {
             $user->addError("password", "Заполни все поля");
         }
     }
     $this->Title = "Регистрация";
     $this->render("registration", array("model" => $user));
 }
Exemplo n.º 17
0
 public function actionRequestResetPw($state = '')
 {
     if (Yii::app()->params['reset_token_hours'] <= 0) {
         throw new CHttpException(404, Yii::t('mc', 'The requested page does not exist.'));
     }
     $model = new User();
     $model->unsetAttributes();
     if (isset($_POST['User'])) {
         $state = 'info';
         $user = false;
         if (strlen(@$_POST['User']['email'])) {
             $model->email = '=' . $_POST['User']['email'];
             $prov = $model->search();
             if ($prov->itemCount === 1) {
                 $user = $prov->getData();
                 $user = $user[0];
             }
         }
         if (!$user || $user->email !== $_POST['User']['email']) {
             Yii::app()->user->setFlash('reset-error', Yii::t('mc', 'No account found for this email address.'));
         } else {
             $ll = substr(md5($user->id . '_' . time() . '_' . rand()), 8, 22);
             $tt = time() + Yii::app()->params['reset_token_hours'] * 3600;
             $l = $tt . 'l' . $ll;
             $user->reset_hash = md5($tt . '_' . $ll);
             if (!$user->save(false)) {
                 Yii::log('Error saving password reset hash for user ' . $user->name);
                 Yii::app()->user->setFlash('reset-error', Yii::t('mc', 'Error generating password reset token.'));
             }
             $message = new YiiMailMessage();
             $message->setFrom(array(Yii::app()->params['admin_email'] => Yii::app()->params['admin_name']));
             $message->setTo(array($user->email => $user->name));
             $message->view = 'resetPw';
             $message->setBody(array('name' => $user->name, 'l' => $l, 'host' => Yii::app()->request->getHostInfo(), 'panel' => Yii::app()->request->getBaseUrl(true)));
             Yii::log('Sending password reset email');
             if (!Yii::app()->mail->send($message)) {
                 Yii::log('Error sending assign password reset link to ' . $user->email);
                 Yii::app()->user->setFlash('reset-error', Yii::t('mc', 'Error sending password reset link.'));
             } else {
                 Yii::app()->user->setFlash('reset-success', Yii::t('mc', 'A password reset link has been sent to your email address.'));
             }
         }
         $this->redirect(array('site/requestResetPw', 'state' => 'info'));
     }
     $this->render('requestResetPw', array('model' => $model, 'state' => $state));
 }
Exemplo n.º 18
0
 /**
  * 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));
 }
Exemplo n.º 19
0
 public function actionForget()
 {
     $model = new ForgetForm();
     if (isset($_POST['ForgetForm'])) {
         $model->attributes = $_POST['ForgetForm'];
         if ($model->validate()) {
             $acc = Account::model()->findByAttributes(array('username' => $model->username));
             if (empty($acc)) {
                 $confirm = "The Username is not exist!";
                 Yii::app()->user->setFlash('forget', $confirm);
                 $this->refresh();
                 return;
             } else {
                 if ($acc->email != $model->email) {
                     $confirm = "Email is not right!";
                     Yii::app()->user->setFlash('forget', $confirm);
                     $this->refresh();
                     return;
                 }
             }
             $newPass = $this->_getRandId(Yii::app()->params['passwordLength']);
             $acc->password = $acc->hashPassword($newPass);
             if (!$acc->save()) {
                 Yii::app()->user->setFlash('forget', "Error!");
             }
             Yii::import('application.extensions.yii-mail.YiiMailMessage');
             $message = new YiiMailMessage();
             $message->setTo($model->email);
             $message->setFrom(array(Yii::app()->params['siteEmail'] => Yii::app()->params['siteName']));
             $subject = "Password Reset";
             $message->setSubject($subject);
             /*$body = "Username: "******"
               \r\nNew password: "******"Your new password has been sent to your email.";
             Yii::app()->user->setFlash('forget', $confirm);
             $this->refresh();
         }
     }
     $this->render('forget', array('model' => $model));
 }
Exemplo n.º 20
0
 protected function sendEmail()
 {
     /**
      * @var $cmd CDbCommand
      */
     $cmd = Yii::app()->db->createCommand();
     $organizations = $cmd->select('organization_id')->from(Job::model()->tableName())->where('task_id=:task_id AND notified=:notified', array(':task_id' => $this->id, 'notified' => '0'))->queryColumn();
     if (count($organizations)) {
         $ids = implode(',', $organizations);
         $emails = Yii::app()->db->createCommand()->select('email')->from(User::model()->tableName())->where("organization_id IN ({$ids})", array())->queryColumn();
         if (count($emails)) {
             Yii::import('ext.yii-mail.YiiMailMessage');
             $params = array('task' => $this);
             $message = new YiiMailMessage();
             $message->view = "task/new";
             $message->subject = __('New task created: :task', array(':task' => $this->name));
             $message->from = Yii::app()->params['adminEmail'];
             $message->setBody($params, 'text/html');
             $message->setTo($emails);
             if ($count = Yii::app()->mail->send($message)) {
                 $cmd = Yii::app()->db->createCommand();
                 $cmd->update(Job::model()->tableName(), array('notified' => 1), "task_id={$this->id} AND organization_id IN ({$ids})");
                 Yii::app()->user->setFlash('info', __('Email notification has been sent to :count users', array(':count' => $count)));
             }
         }
     }
 }
 public function actionEnvioCorreoVenta($idIngreso)
 {
     $model = Ingresos::model()->findByPk($idIngreso);
     $message = new YiiMailMessage();
     $message->subject = 'Detalle de Venta: N° ' . $model->id;
     /*$message->view ='prueba';//nombre de la vista q conformara el mail*/
     $message->setBody('<b>Venta número:</b>' . $model->id . '<br>
     				   <b>Fecha de Venta:</b>' . Yii::app()->dateformatter->format("dd-MM-yyyy H:m:s", $model->fecha) . '<br><br>
     				   <b>Doc. Paciente:</b><br>' . $model->paciente->n_identificacion . '<br>
     				   <b>Paciente:</b><br>' . $model->paciente->nombreCompleto . '<br>
     				   <b>Forma de Pago:</b><br>' . $model->forma_pago . '<br>
     				   <b>Valor:</b><br>' . $model->valor . '<br>
     				   <b>Centro de Costos:</b><br>' . $model->centroCosto->nombre . '<br>
     				   <b>Comentario:</b><br>' . $model->descripcion . '<br><br>
     				   <b>Usuario que Creo:</b><br>' . $model->personal->nombreCompleto . '<br><br>', 'text/html');
     //codificar el html de la vista
     $message->from = '*****@*****.**';
     // alias del q envia
     //recorrer a los miembros del equipo
     $message->setTo('*****@*****.**');
     // a quien se le envia
     Yii::app()->mail->send($message);
 }
 public function actionEnvioCorreoEgresos($idEgreso)
 {
     $model = Egresos::model()->findByPk($idEgreso);
     Yii::import('ext.yii-mail.YiiMailMessage');
     $message = new YiiMailMessage();
     //$message = Yii::app()->Smtpmail;
     $message->subject = 'Detalle de Egreso';
     /*$message->view ='prueba';//nombre de la vista q conformara el mail*/
     $message->setBody('<b>Egreso número:</b>' . $model->id . '<br>
     				   <b>Fecha Egreso:</b>' . Yii::app()->dateformatter->format("dd-MM-yyyy H:m:s", $model->fecha) . '<br><br>
     				   <b>Doc. Beneficiario:</b><br>' . $model->n_identificacion . '<br>
     				   <b>Beneficiario:</b><br>' . $model->proveedor->nombre . '<br>
     				   <b>Forma de Pago:</b><br>' . $model->forma_pago . '<br>
     				   <b>Valor: $ </b><br>' . $model->total_egreso . '<br>
     				   <b>Centro de Costos:</b><br>' . $model->centroCosto->nombre . '<br>
     				   <b>Comentario:</b><br>' . $model->observaciones . '<br><br>
     				   <b>Usuario que Creo:</b><br>' . $model->personal->nombreCompleto . '<br><br>', 'text/html');
     //codificar el html de la vista
     $message->from = '*****@*****.**';
     // alias del q envia
     //recorrer a los miembros del equipo
     $message->setTo(array('*****@*****.**', '*****@*****.**'));
     // a quien se le envia
     //$message->setTo('gerencia@smadiaclinic.com hramirez@myrs.com.co'); // a quien se le envia
     Yii::app()->mail->send($message);
 }
 public function actionEnvioCorreoIngreso($idIngreso)
 {
     $model = Ingresos::model()->findByPk($idIngreso);
     Yii::import('ext.yii-mail.YiiMailMessage');
     $message = new YiiMailMessage();
     //$message = Yii::app()->Smtpmail;
     $message->subject = 'Detalle de Ingreso';
     /*$message->view ='prueba';//nombre de la vista q conformara el mail*/
     $message->setBody('<b>Ingreso número:</b>' . $model->id . '<br>
     				   <b>Fecha Ingreso:</b>' . Yii::app()->dateformatter->format("dd-MM-yyyy H:m:s", $model->fecha) . '<br><br>
     				   <b>Doc. Paciente:</b><br>' . $model->paciente->n_identificacion . '<br>
     				   <b>Paciente:</b><br>' . $model->paciente->nombreCompleto . '<br>
     				   <b>Forma de Pago:</b><br>' . $model->forma_pago . '<br>
     				   <b>Valor: $ </b><br>' . $model->valor . '<br>
     				   <b>Centro de Costos:</b><br>' . $model->centroCosto->nombre . '<br>
     				   <b>Comentario:</b><br>' . $model->descripcion . '<br><br>
     				   <b>Vendedor:</b><br>' . $model->vendedor->nombreCompleto . '<br><br>
     				   <b>Usuario que Creo:</b><br>' . $model->personal->nombreCompleto . '<br><br>', 'text/html');
     //codificar el html de la vista
     $message->from = '*****@*****.**';
     // alias del q envia
     //recorrer a los miembros del equipo
     $message->setTo(array('*****@*****.**'));
     // a quien se le envia
     //$message->setTo('gerencia@smadiaclinic.com hramirez@myrs.com.co'); // a quien se le envia
     Yii::app()->mail->send($message);
     // Yii::import('ext.yii-mail.YiiMailMessage');
     //  $message = new YiiMailMessage;
     //  $message->setBody('Message content here with HTML', 'text');
     //  $message->subject = 'My Subject';
     //  $message->addTo('*****@*****.**');
     //  $message->from = Yii::app()->params['adminEmail'];
     //  Yii::app()->mail->send($message);
 }
 public function actionTestConnection($id)
 {
     $model = $this->loadModel($id);
     //echo "IN ACTION TEST CONNECTION <br>";
     if (!($conn = @fsockopen("google.com", 80, $errno, $errstr, 30))) {
         echo "PLEASE CHECK YOUR INTERNET CONNECTION";
         echo $model->id;
     } else {
         $root = dirname(dirname(__FILE__));
         //echo "<br>".$root;
         $filename = $root . '/config/mail_server.json';
         //echo "<br>file url = ".$filename;
         $send_receive_address = '';
         //echo "INTERNET IS CONNECTED";
         if (file_exists($filename)) {
             //echo "<br>File is present";
             $data = file_get_contents($filename);
             $decodedata = json_decode($data, true);
             $send_receive_address = $decodedata['smtp_username'];
             //echo "<br>email addr = ".$send_receive_address;
         } else {
             //echo "<br>Unable to find valid email address";
         }
         $model = new PurchaseOrder();
         $reciever_email = $send_receive_address;
         $sender_email = $send_receive_address;
         $message = new YiiMailMessage();
         $message->setTo(array($reciever_email));
         $message->setFrom(array($sender_email));
         $message->setSubject('Test');
         $message->setBody("This is a test mail from Stock System");
         # You can easily override default constructor's params
         // 			$mPDF1 = Yii::app()->ePdf->mPDF('', 'A5');
         // 			# render (full page)
         // 			$mPDF1->WriteHTML($this->render('orderPreview',array('model'=>$model,), true));
         // 		    # Load a stylesheet
         // 		    $stylesheet = file_get_contents(Yii::getPathOfAlias('webroot.css') . '/main.css');
         // 		    $message->setBody($mPDF1->WriteHTML($stylesheet, 1));
         //$message->setBody('THIS IS TEST MAIL');
         //$numsent = Yii::app()->mail->send($message);
         if (Yii::app()->mail->send($message)) {
             echo "TEST EMAIL IS SENT, CONNECTION IS OK<br>";
         }
     }
     //end of else.
 }
Exemplo n.º 25
0
 public function setOwner($id)
 {
     if (is_object($id)) {
         $id = $id->id;
     }
     $prev = $this->owner;
     $res = true;
     if ($id != $prev) {
         Yii::log('Changing owner of server ' . $this->id . ' from ' . $prev . ' to ' . $id);
     }
     if ($id) {
         $sql = 'replace into `user_server` (`user_id`,`server_id`, `role`) values(?,?,?)';
         $cmd = Yii::app()->db->createCommand($sql);
         $cmd->bindValue(1, (int) $id);
         $cmd->bindValue(2, $this->id);
         $cmd->bindValue(3, 'owner');
         $res = $cmd->execute();
     }
     //FtpUserServer::model()->deleteAllByAttributes(array('server_id'=>$this->id));
     $sql = 'update `user_server` set `role`=? where `server_id`=? and `user_id`!=? and `role`=?';
     $cmd = Yii::app()->db->createCommand($sql);
     $cmd->bindValue(1, 'admin');
     $cmd->bindValue(2, $this->id);
     $cmd->bindValue(3, $id ? (int) $id : 0);
     $cmd->bindValue(4, 'owner');
     $cmd->execute();
     if ($id != $prev && $this->sendData && Yii::app()->params['mail_assign'] && ($usr = User::model()->findByPk($id))) {
         $msg = new YiiMailMessage();
         $msg->setFrom(array(Yii::app()->params['admin_email'] => Yii::app()->params['admin_name']));
         $msg->setTo(array($usr->email => $usr->name));
         $msg->view = 'serverAssigned';
         $msg->setBody(array('server_id' => $this->id, 'user_id' => $id, 'user_name' => $usr->name, 'host' => Yii::app()->request->getHostInfo(), 'panel' => Yii::app()->request->getBaseUrl(true)));
         Yii::log('Seding assign email to ' . $usr->email);
         if (!Yii::app()->mail->send($msg)) {
             Yii::log('Error sending assign email to ' . $usr->email);
         } else {
             $this->sendData = false;
         }
     }
     return $res;
 }
    public function actionEnvioCorreo($idCita)
    {
        $model = Citas::model()->findByPk($idCita);
        $lahora = HorasServicio::model()->findByPK($model->hora_fin + 1);
        //Buscar Correo en la plantilla
        $plantillaCorreo = Correos::model()->findByPK(1);
        $elCorreo = $model->paciente->email;
        if (filter_var($elCorreo, FILTER_VALIDATE_EMAIL)) {
            $soloCorreo = array($elCorreo);
            Yii::import('ext.yii-mail.YiiMailMessage');
            $message = new YiiMailMessage();
            //$message = Yii::app()->Smtpmail;
            $message->subject = 'Notificación de Cita en SMADIA Clinic: N° ' . $model->id;
            /*$message->view ='prueba';//nombre de la vista q conformara el mail*/
            $message->setBody('<br><b>Apreciado Sr (a). : </b>' . $model->paciente->nombreCompleto . '<br><br>
	        				   Su Cita N°: ' . $model->id . ' de <b>' . $model->lineaServicio->nombre . '</b> en Smadia Clinic se encuentra agendada para el día: <b>' . Yii::app()->dateformatter->format("dd-MM-yyyy", $model->fecha_cita) . '</b>
	        				   a las: <b>' . $model->horaInicio->hora . '</b> con el <b>' . $model->personal->idPerfil->nombre . ' ' . $model->personal->nombreCompleto . '.</b>
	        <br><br>' . $plantillaCorreo->detalle . '<br>' . $plantillaCorreo->pie . '', 'text/html');
            //codificar el html de la vista
            $message->from = '*****@*****.**';
            // alias del q envia
            //recorrer a los miembros del equipo
            $message->setTo($soloCorreo);
            // a quien se le envia
            //$message->setTo('gerencia@smadiaclinic.com hramirez@myrs.com.co'); // a quien se le envia
            Yii::app()->mail->send($message);
            //Yii::app()->user->setFlash('success',"El correo es. " .$elCorreo);
        } else {
            Yii::app()->user->setFlash('error', "No se envio confirmación por correo electrónico." . $elCorreo);
        }
        //Yii::app()->user->setFlash('success',"Se entro al proceso de correo. " .$plantillaCorreo->id);
    }
Exemplo n.º 27
0
 public function afterSave()
 {
     $name = $this->name;
     if (@strlen($this->prevName) && $this->prevName != $name) {
         $name = $this->prevName;
     }
     $ftpUser = FtpUser::model()->findByAttributes(array('name' => $name));
     if ($ftpUser) {
         $ftpUser->syncWithUser($this);
         $ftpUser->save();
     }
     if ($this->sendData && $this->_sendPassword !== false) {
         $msg = new YiiMailMessage();
         $msg->setFrom(array(Yii::app()->params['admin_email'] => Yii::app()->params['admin_name']));
         $msg->setTo(array($this->email => $this->name));
         if ($this->isNewRecord) {
             $msg->view = 'welcome';
         } else {
             $msg->view = 'password';
         }
         $msg->setBody(array('password' => $this->_sendPassword, 'id' => $this->id, 'name' => $this->name, 'email' => $this->email, 'host' => Yii::app()->request->getHostInfo(), 'panel' => Yii::app()->request->getBaseUrl(true)));
         Yii::log('Seding welcome email to ' . $this->email);
         if (!Yii::app()->mail->send($msg)) {
             Yii::log('Error sending welcome email to ' . $this->email);
         } else {
             $this->_sendPassword = false;
             $this->sendData = false;
         }
     }
     return parent::afterSave();
 }
 public function actionCancelItems($id)
 {
     $model = $this->loadModel($id);
     $quantity_cancelled = $model->quantity_ordered - $model->quantity_recieved;
     $model->comments .= '<br>' . $quantity_cancelled . ' quantity have been cancelled by the user ' . Yii::app()->user->name;
     $model->comments .= ' on ' . date("F j, Y, g:i a");
     $model->quantity_ordered = $model->quantity_recieved;
     if ($quantity_cancelled == $model->quantity_ordered) {
         $model->item_status = 11;
         //item status will be changed to cancelled
     } else {
         $model->item_status = 3;
         //item status will be changed to recieeved
     }
     $item_total_price_before = $model->total_price;
     $model->total_price = $model->quantity_recieved * $model->unit_price;
     $purchaseOrderQueryModel = PurchaseOrder::model()->findByPk($model->purchase_order_id);
     /*HERE IT IS ONLY DEDUCTED BECASUSE IT WILL BE AUTOMATIUCALLY ADDED LATER AFTER FUNCTION*/
     $ameneded_total_cost = $purchaseOrderQueryModel->total_cost - $item_total_price_before;
     PurchaseOrder::model()->updateByPk($model->purchase_order_id, array('total_cost' => $ameneded_total_cost));
     if ($model->save()) {
         /*I WIL SEND EMAIL FIRST*/
         $reciever_email = $purchaseOrderQueryModel->suppliers->email;
         $reciever_name = $purchaseOrderQueryModel->suppliers->contact_person;
         $sender_email = Yii::app()->params['adminEmail'];
         $sender_name = Yii::app()->params['company_name'];
         $message = new YiiMailMessage();
         $message->setTo(array($reciever_email => $reciever_name));
         $message->setFrom(array($sender_email => $sender_name));
         $message->setSubject('Items Cancelled - Purchase Order: ' . $purchaseOrderQueryModel->order_number . ' ');
         $msg_body = 'Dear Sir, <br> This is to remind you that we are cancelling the following items from the order as we have not got the delivery of it.<br>';
         $msg_body .= '<table><tr><th>Name</th><th>Part Number</th><th>Quantity Ordered</th><th>Quantity Cancelled</th></tr>';
         $msg_body .= '<tr><td>' . $model->items->name . '</td><td>' . $model->items->part_number . '</td><td>' . $model->quantity_ordered . '</td><td>' . $quantity_cancelled . '</td></tr></table>';
         $msg_body .= 'Please Update the Purchase Order Copy <hr>';
         $msg_body .= $this->renderPartial('/purchaseOrder/finaliseOrder', array('model' => $purchaseOrderQueryModel), true);
         $message->setBody($msg_body, 'text/html');
         $numsent = Yii::app()->mail->send($message);
         $numsent = 1;
         if ($numsent == 1) {
             echo 'Supplier Notified for cancellation';
             $this->redirect(array('/purchaseOrder/orderRecieved/', 'id' => $model->purchase_order_id));
         } else {
             $this->raiseEvent('Error', 'error');
         }
         //end of else
         //echo "in itemOnOrder controller";
         $this->redirect(array('/PurchaseOrder/orderRecieved', 'id' => $model->purchase_order_id));
     } else {
         echo 'error in updating ';
     }
 }
Exemplo n.º 29
0
 public function notificar($asunto, $mensaje)
 {
     // //     Envia una notificacion al usuario.
     set_time_limit(0);
     ini_set('max_execution_time', 0);
     // 	$config=Yii::app()->getParams(false);
     $message = new YiiMailMessage();
     $message->setCharset('UTF8');
     $message->setTo($this->UsuariosEmail);
     $message->setFrom('*****@*****.**');
     $message->setSubject($asunto);
     $message->setBody($mensaje, 'Text/HTML');
     return Yii::app()->mail->send($message) ? true : false;
 }