Exemple #1
0
 /**
  * @static send a email
  * @param array $data
  *      array('subject'=>?, 'params'=>array(), 'view'=>?, 'to'=>?, 'from'=>?)
  * @param bool $requireView if true, it will only send email if view is existed
  */
 public static function mail($data, $requireView = false)
 {
     //        self::_setTestEmail($data, '*****@*****.**');
     $message = new YiiMailMessage($data['subject']);
     if (isset($data['view'])) {
         if ($requireView) {
             $path = YiiBase::getPathOfAlias(Yii::app()->mail->viewPath) . '/' . $data['view'] . '.php';
             if (!file_exists($path)) {
                 return;
             }
         }
         $message->view = $data['view'];
     } elseif ($requireView) {
         return;
     }
     $message->setBody($data['params'], 'text/html');
     if (is_array($data['to'])) {
         foreach ($data['to'] as $t) {
             $message->addTo($t);
         }
     } else {
         $message->addTo($data['to']);
     }
     $message->from = $data['from'];
     $message->setFrom(array($data['from'] => Yii::app()->setting->getItem('title_all_mail')));
     // test email using local mail server
     if ($_SERVER['HTTP_HOST'] == 'localhost') {
         Yii::app()->mail->transportType = 'smtp';
         Yii::app()->mail->transportOptions = array('host' => 'localhost', 'username' => null, 'password' => null);
     }
     return Yii::app()->mail->send($message);
 }
 /**
  * Envia e-mail de recuperação de senha 
  */
 public function recover()
 {
     if (!$this->validate()) {
         return false;
     }
     $usuario = Usuario::model()->ativos()->find("email = ?", array($this->email));
     if ($usuario == null) {
         $this->addError('email', Yii::t('RecuperarSenhaForm', 'Este e-mail está incorreto ou não está cadastrado.'));
         return false;
     }
     $usuario->geraTokenRecuperacaoSenha();
     $assunto = 'Recuperação de senha';
     $view = Yii::app()->controller->renderFile(Yii::getPathOfAlias('application.views.mail') . '/recuperarSenha.php', array('usuario' => $usuario), true);
     $email = new YiiMailMessage();
     $email->view = "template";
     $email->setBody(array('content' => $view, 'title' => $assunto), 'text/html');
     $email->subject = $assunto;
     $email->addTo($this->email);
     $email->from = Yii::app()->params['adminEmail'];
     try {
         Yii::app()->mail->send($email);
     } catch (Exception $e) {
         Yii::log('Erro ao enviar o e-mail:  ' . $e->getMessage(), CLogger::LEVEL_ERROR);
         return false;
     }
     return true;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     if (!empty($id) && !Yii::app()->user->isGuest) {
         $customer_email = Yii::app()->user->name;
         $customerModel = Customer::model()->findByAttributes(array('customer_email' => $customer_email));
         $productId = $id;
         $productModel = Product::model()->findByPk($productId);
         $model = new Order();
         $model->order_product_id = $productModel->product_id;
         $model->order_customer_id = $customerModel->customer_id;
         $model->order_amount = $productModel->product_price + $productModel->product_shipping_price;
         if ($model->save()) {
             $attribuits = Order::model()->findByPk($model->order_id);
             $str = "Product Name:{$productModel->product_name}\r\n" . "Order Id:{$attribuits->order_id}\r\n" . "Order Product Id:{$attribuits->order_product_id}\r\n" . "Order Customer Id:{$attribuits->order_customer_id}\r\n" . "Total Amount With Shipping Charges:{$attribuits->order_amount}\r\n";
             $message = new YiiMailMessage();
             $message->subject = "Your order details";
             $message->setBody($str);
             $message->addTo(Yii::app()->user->name);
             $message->from = $customerModel->customer_email;
             Yii::app()->mail->send($message);
             $this->redirect(array('view', 'id' => $model->order_id));
         } else {
             echo "booking failed";
         }
     }
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $message = new YiiMailMessage();
     //this points to the file test.php inside the view path
     $message->view = "login";
     $params = array('name' => '*****@*****.**');
     $message->subject = 'My TestSubject';
     $message->setBody($params, 'text/html');
     $message->addTo('*****@*****.**');
     $message->from = '*****@*****.**';
     //Yii::app()->mail->send($message);
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $login_model = new LoginForm();
     $sign_model = new User();
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
         echo CActiveForm::validate($login_model);
         Yii::app()->end();
     }
     // collect user input data
     if (isset($_POST['LoginForm'])) {
         $login_model->attributes = $_POST['LoginForm'];
         // validate user input and redirect to the previous page if valid
         if ($login_model->validate() && $login_model->login()) {
             $this->redirect(Yii::app()->user->returnUrl);
         }
     }
     // display the login form
     $this->render('index', array('login_model' => $login_model, 'sign_model' => $sign_model));
 }
 /**
  * Send reminder emails to those who haven't paid for their next week's box
  */
 public function actionSendReminderEmails()
 {
     $Customers = Customer::model()->findAllWithNoOrders();
     foreach ($Customers as $Cust) {
         $validator = new CEmailValidator();
         if ($validator->validateValue(trim($Cust->User->email))) {
             $User = $Cust->User;
             $User->auto_login_key = $User->generatePassword(50, 4);
             $User->update_time = new CDbExpression('NOW()');
             $User->update();
             $adminEmail = SnapUtil::config('boxomatic/adminEmail');
             $adminEmailFromName = SnapUtil::config('boxomatic/adminEmailFromName');
             $message = new YiiMailMessage('Running out of orders');
             $message->view = 'customer_running_out_of_orders';
             $message->setBody(array('Customer' => $Cust, 'User' => $User), 'text/html');
             $message->addTo($Cust->User->email);
             $message->addBcc($adminEmail);
             //$message->addTo('*****@*****.**');
             $message->setFrom(array($adminEmail => $adminEmailFromName));
             if (!@Yii::app()->mail->send($message)) {
                 echo '<p style="color:red"><strong>Email failed sending to: ' . $Cust->User->email . '</strong></p>';
             } else {
                 echo '<p>Running out of orders message sent to: ' . $Cust->User->email . '</p>';
             }
         } else {
             echo '<p style="color:red"><strong>Email not valid: "' . $Cust->User->email . '"</strong></p>';
         }
     }
     echo '<p><strong>Finished.</strong></p>';
     //Yii::app()->end();
 }
 public function actionEmail1()
 {
     $message = new YiiMailMessage();
     $message->setBody('Message content here with HTML', 'text/html');
     $message->subject = 'My Subject';
     $message->addTo('*****@*****.**');
     $message->from = Yii::app()->params['adminEmail'];
     Yii::app()->mail->send($message);
 }
Exemple #7
0
 /**
  *
  * 邮件发送方法
  * @param string $email 邮件发送地址
  * @param string $subject 邮件发送标题
  * @param string $body 邮件发送内容
  */
 public static function send($email, $subject, $body)
 {
     $message = new YiiMailMessage();
     $message->setBody($body, 'text/html');
     $message->subject = $subject;
     $message->addTo($email);
     $message->setFrom(array('*****@*****.**' => "萤火虫"));
     return Yii::app()->mail->send($message);
 }
 public function SendMail($email = "", $subject = '', $message = "")
 {
     $mail = new YiiMailMessage();
     $mail->setBody($message, 'text/html');
     $mail->subject = $subject;
     $mail->addTo($email);
     $mail->from = Yii::app()->params['regEmail'];
     $mail->setFrom(array('*****@*****.**' => 'Столица Скидок'));
     return Yii::app()->mail_reg->send($mail);
 }
Exemple #9
0
 public function enviar()
 {
     $message = new YiiMailMessage();
     $message->from = $this->email;
     $message->addTo(Yii::app()->params['adminEmail']);
     $message->subject = $this->subject;
     $message->view = "template";
     $view = Yii::app()->controller->renderFile(Yii::getPathOfAlias('application.modules.pizzaria.views.mail') . '/contato.php', array('de' => $this->name, 'email' => $this->email, 'mensagem' => $this->message), true);
     $message->setBody(array('content' => $view, 'title' => $this->subject), 'text/html');
     return Yii::app()->mail->send($message) ? true : false;
 }
Exemple #10
0
 /**
  * @author softdev
  * @param string $subject
  * @param string $email
  * @param array $param
  * @param string $view
  */
 public function SendMail($subject = '', $email, $param, $link = '', $view)
 {
     $message = new YiiMailMessage();
     //this points to the file test.php inside the view path
     $message->view = trim($view);
     $params = array('params' => $param, 'link' => $_SERVER['HTTP_ORIGIN'] . $link);
     $message->subject = $subject;
     $message->setBody($params, 'text/html');
     $message->addTo(trim($email));
     $message->from = Yii::app()->params['adminEmail'];
     Yii::app()->mail->send($message);
 }
 public function SendMail($data, $detail)
 {
     Yii::import('ext.yii-mail.YiiMailMessage');
     $message = new YiiMailMessage();
     $message->view = "price_submission";
     $params = array('data' => $data, 'detail' => $detail);
     $message->setBody($params, 'text/html');
     $message->subject = "Price calculation submission";
     $message->addTo($data->email);
     $message->from = Yii::app()->params['adminEmail'];
     if (Yii::app()->mail->send($message)) {
         return "sukses";
     }
 }
Exemple #12
0
 protected function sendMail($to, $subject, $body, $att = null)
 {
     Yii::import('ext.yii-mail.YiiMailMessage');
     $message = new YiiMailMessage();
     $message->setBody($body);
     $message->subject = $subject;
     $message->addTo($to);
     $message->from = Yii::app()->params['adminEmail'];
     if ($att) {
         $swiftAttachment = Swift_Attachment::fromPath($att);
         $message->attach($swiftAttachment);
     }
     return Yii::app()->mail->send($message);
 }
 public function actionTeste()
 {
     Yii::import('ext.yii-mail.YiiMailMessage');
     $message = new YiiMailMessage();
     $message->setBody('Message content here with HTML', 'text/html');
     $message->subject = 'My Subject';
     $message->addTo('*****@*****.**');
     $message->from = Yii::app()->params['adminEmail'];
     if (Yii::app()->mail->send($message)) {
         echo 'E-mail enviado com sucesso';
     } else {
         echo 'Falha ao tentar enviar o e-mail';
     }
 }
Exemple #14
0
 public static function sendMail($data)
 {
     //        self::_setTestEmail($data, '*****@*****.**');
     $message = new YiiMailMessage($data['subject']);
     $message->setBody($data['message'], 'text/html');
     if (is_array($data['to'])) {
         foreach ($data['to'] as $t) {
             $message->addTo($t);
         }
     } else {
         $message->addTo($data['to']);
     }
     if (isset($data['cc'])) {
         $message->setCc($data['cc']);
     }
     $message->from = $data['from'];
     $message->setFrom(array($data['from'] => Yii::app()->setting->getItem('title_all_mail')));
     // test email using local mail server
     if ($_SERVER['HTTP_HOST'] == 'localhost') {
         Yii::app()->mail->transportType = 'smtp';
         Yii::app()->mail->transportOptions = array('host' => 'localhost', 'username' => null, 'password' => null);
     }
     return Yii::app()->mail->send($message);
 }
Exemple #15
0
 public function enviarCorreo($idmiembro)
 {
     $miembro = Miembro::model()->findByPk($idmiembro);
     Yii::log('miembro pwd ' . $miembro->password);
     $body = "Sus datos de acceso al sistema de SOMIM son los siguientes:\n";
     $body .= "Dirección de correo electrónico: " . $miembro->email;
     $body .= "Contraseña: " . $miembro->password;
     $message = new YiiMailMessage();
     $message->subject = 'Acceso SOMIM';
     $message->setBody($body, 'text/html');
     $message->addTo($miembro->email);
     $message->from = '*****@*****.**';
     Yii::app()->mail->send($message);
     return true;
 }
Exemple #16
0
 /**
  * $data = array(
  *	'view'=>'mail',
  *	'server'=>'*****@*****.**',
  *	'data'=>array(
  *		'email'=>'*****@*****.**'
  *	)
  *);
  *$this->SendMail('*****@*****.**','asdad',$data,'layout');
  **/
 public function SendMail($mailTo = '', $subject = '', $params = array(), $layout = 'layout')
 {
     if (isset($params['server']) && $params['server'] != '') {
         $mailFrom = $params['server'];
     }
     $message = new YiiMailMessage();
     $message->view = $layout;
     $sid = 1;
     $params = $params;
     $message->subject = $subject;
     //$message->from = $mailFrom;
     $message->setBody($params, 'text/html');
     $message->addTo($mailTo);
     return Yii::app()->mail->send($message);
 }
Exemple #17
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;
     }
 }
Exemple #18
0
 public static function sentMail($id, $templateId, $to, $params = array())
 {
     $emailModel = EmailTemplateModel::model()->findByPk($templateId);
     if (!empty($emailModel)) {
         $message = new YiiMailMessage();
         $message->setBody(strtr($emailModel->body, $params), 'text/html');
         $message->subject = strtr($emailModel->subject, $params);
         $message->addTo($to);
         $message->from = isset($emailModel->from) && $emailModel->from != "" ? $emailModel->from : "*****@*****.**";
         if (Yii::app()->mail->send($message)) {
             $emailQueue = EmailQueueModel::model()->findByPk($id);
             $emailQueue->status = 1;
             $emailQueue->save();
             return true;
         }
     }
     return false;
 }
 /**
  * Displays the contact page
  */
 public function actionContact()
 {
     $this->layout = '//layouts/column1';
     $model = new ContactForm();
     if (isset($_POST['ContactForm'])) {
         $model->attributes = $_POST['ContactForm'];
         if ($model->validate()) {
             $headers = "From: {$model->name}<br>" . "Reply-To: {$model->email}<br>" . "Content: <br>" . "{$model->body}";
             Yii::import('ext.yii-mail.YiiMailMessage');
             $message = new YiiMailMessage();
             $message->setBody($headers, 'text/html');
             $message->subject = $model->subject;
             $message->addTo(Yii::app()->params['adminEmail']);
             $message->from = Yii::app()->params['adminEmail'];
             Yii::app()->mail->send($message);
             Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
             $this->refresh();
         }
     }
     $this->render('contact', array('model' => $model));
 }
Exemple #20
0
 /**
  * Displays the contact page
  */
 public function actionContact()
 {
     $model = new ContactForm();
     if (isset($_POST['ContactForm'])) {
         $model->attributes = $_POST['ContactForm'];
         if ($model->validate()) {
             /*				$headers="From: {$model->email}\r\nReply-To: {$model->email}";
             				mail(Yii::app()->params['adminEmail'],$model->subject,$model->body,$headers);
             				Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
             				
             */
             Yii::import('ext.yii-mail.YiiMailMessage');
             $message = new YiiMailMessage();
             $message->setBody($model->body, 'text/html');
             $message->subject = $model->subject;
             $message->addTo('*****@*****.**');
             $message->from = Yii::app()->params['adminEmail'];
             Yii::app()->mail->send($message);
         }
     }
     $this->render('contact', array('model' => $model));
 }
 public function forgetPassword()
 {
     if ($this->email != '') {
         $check = User::model()->findByAttributes(array('email' => $this->email));
         if ($check != '') {
             $password = substr($check->password, 0, 10);
             $check->password = $check->hashPassword($password);
             $check->saveAttributes(array('password'));
             $mail = new YiiMailMessage();
             $mail->subject = 'Hệ thống reset mật khẩu ' . Yii::app()->getBaseUrl(true);
             $body = '<p>Mật khẩu mới của bạn là: <strong>' . $password . '</strong></p>
                     Click <a taget="_blank" href="' . Yii::app()->getBaseUrl(true) . '/admin">vào đây</a> để đi đến website và thay đổi lại mật khẩu';
             $mail->setBody($body, 'text/html');
             $mail->addTo($this->email);
             $mail->from = Yii::app()->params['adminEmail'];
             Yii::app()->mail->send($mail);
             return true;
         } else {
             return false;
         }
     }
 }
 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));
 }
Exemple #23
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());
         }
     }
 }
Exemple #24
0
 public function send()
 {
     if (!$this->validate()) {
         return false;
     }
     if (!$this->isNewRecord) {
         throw new CHttpException(500, "Системная ошибка Mail::send::notNewRecord");
     }
     if (!$this->buddy instanceof User) {
         throw new CHttpException(500, "Системная ошибка Mail::send::buddyNotUser");
     }
     // 2. Помещаем письмо в свои исходящие
     $sent = clone $this;
     $sent->folder = self::SENT;
     $sent->user_id = Yii::app()->user->id;
     $sent->buddy_id = $this->buddy->id;
     $sent->seen = true;
     // 1. Помещаем письмо в инбокс получателя
     $this->folder = self::INBOX;
     $this->user_id = $this->buddy->id;
     $this->buddy_id = Yii::app()->user->id;
     $this->seen = false;
     if (!$this->save()) {
         return false;
     }
     if (!$sent->save()) {
         return false;
     }
     // 3. Если нужно, шлём почту получателю
     if ($this->buddy->ini_get(User::INI_MAIL_PMAIL)) {
         $msg = new YiiMailMessage("Вам письмо! Тема: \"" . $this->subj . "\"");
         $msg->view = "mail";
         $msg->setFrom(array(Yii::app()->params["systemEmail"] => Yii::app()->user->login . " - письмо"));
         $msg->addTo($this->buddy->email);
         $msg->setBody(array("message" => $this), "text/html");
         Yii::app()->mail->send($msg);
     }
     return true;
 }
Exemple #25
0
 public function actionResult($id)
 {
     $list_id = "";
     $list_side = "";
     $list = explode(",", $id);
     for ($i = 0; $i < count($list); $i++) {
         $tmp = explode("_", $list[$i]);
         $list_id[] = $tmp[0];
         $list_side[] = $tmp[1];
     }
     $strid = implode(",", $list_id);
     $this->pageTit = $this->maketit(substr($strid, 0, strlen($strid) - 1), 1);
     $cfmodel = new ContactForm();
     if (isset($_POST['ContactForm'])) {
         $cfmodel->attributes = $_POST['ContactForm'];
         if ($cfmodel->validate()) {
             /*			$headers="From: {$cfmodel->email}\r\nReply-To: {$cfmodel->email}";
             				mail(Yii::app()->params['adminEmail'],$cfmodel->subject,$cfmodel->body,$headers);
             				Yii::app()->user->setFlash('contact','Спасибо за заказ. Ответ последует сегодня же.');
             				$this->refresh();
             */
             Yii::import('ext.yii-mail.YiiMailMessage');
             $message = new YiiMailMessage();
             $message->setBody("" . $cfmodel->linky . "<p>" . $cfmodel->body, 'text/html');
             $message->subject = "Ref: " . $cfmodel->name . " /" . $cfmodel->email . " /" . $cfmodel->subject;
             $message->addTo('*****@*****.**');
             $message->from = Yii::app()->params['adminEmail'];
             Yii::app()->mail->send($message);
             $this->render('end', array('model' => $cfmodel));
             return;
         }
     }
     $model = new Bb('search');
     $this->render('viewr', array('model' => $model, 'fmodel' => $cfmodel, 'list' => $list_id, 'lists' => $list_side));
 }
Exemple #26
0
 public function actionNew()
 {
     //cek eror tidaknya
     // foreach  ($_FILES['fileupload']['error'] as $error ){
     // 	// if ($error
     // 	if  ($error==0)
     // 		$no_error = true;
     // 	else
     // 		$no_error = false;
     // }
     // print_r($_FILES['fileupload']);
     // exit;
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $model = new Project();
         $model->id_member = $_REQUEST['member'];
         $model->project_name = $_REQUEST['name'];
         $model->start_date = $_REQUEST['start'];
         $model->due_date = $_REQUEST['due'];
         $model->username = 1;
         $model->task = 1;
         $model->progres = 0;
         $model->priority = 1;
         $model->worker = 0;
         $model->status = 1;
         if ($model->save()) {
             $calendar = new Calendar();
             $calendar->project_id = $model->id;
             $calendar->start_date = $_REQUEST['start'];
             $calendar->due_date = $_REQUEST['due'];
             $calendar->description = $_REQUEST['descriptionca'] . " of ";
             $calendar->type = "due";
             if ($calendar->save()) {
                 // echo "sukses";
                 if ($no_error) {
                     $time = time();
                     $hm = new ProjectCommentHead();
                     $hm->datetime = date('Y-m-d H:i:s');
                     $hm->user_id = 1;
                     $hm->project_id = $model->id;
                     $hm->type = 1;
                     if ($hm->save()) {
                         $transaction->commit();
                         // foreach($_FILES['fileupload']['tmp_name'] as $key => $tmp_name ){
                         // 	$comment = new ProjectComment;
                         // 	$file_name = $_FILES['fileupload']['name'][$key];
                         // 	$file_size =$_FILES['fileupload']['size'][$key];
                         // 	$file_tmp =$_FILES['fileupload']['tmp_name'][$key];
                         // 	$file_type=$_FILES['fileupload']['type'][$key];
                         // 	// echo Yii::app()->request->baseUrl."/img/comment/".".$file_name";
                         // 	$comment->name_file = $key.$time.$file_name;
                         // 	$comment->head_project_id = $hm->id;
                         // 	$comment->comment_id = 0;
                         // 	if  ($comment->save()){
                         // 		if (move_uploaded_file($file_tmp,Yii::app()->basePath."/../img/comment/$key$time$file_name")){
                         // 			// echo "sukses";
                         // 		}
                         // 		// else{
                         // 		// 	// echo "sukses";
                         // 		// }
                         // 	}
                         // 	// echo $file_name. " ";
                         // }
                     }
                 }
                 //kirim email start
                 Yii::import('ext.yii-mail.YiiMailMessage');
                 $message = new YiiMailMessage();
                 $message->view = "project_notif";
                 $params = array('email' => $email, 'name' => $name, 'code' => $code);
                 $message->setBody($params, 'text/html');
                 $message->subject = "New Project on vvfy";
                 $message->addTo("*****@*****.**");
                 $message->addTo("*****@*****.**");
                 $message->addTo("*****@*****.**");
                 $message->addTo("*****@*****.**");
                 $message->from = Yii::app()->params['adminEmail'];
                 //  emails to keep in cc
                 // $emails = array("*****@*****.**","*****@*****.**");
                 // // foreach($emails as $value){
                 //    $message->addCC(trim($value));
                 // }
                 // $message->from = "Support";
                 // if (Yii::app()->mail->send($message))
                 echo "sukses";
                 // else
                 // echo "gagal";
                 //kirim emai end
             }
             // echo "sukses";
         } else {
             echo json_encode($model->getErrors());
         }
     } catch (Exception $e) {
         $transaction->rollBack();
         // other actions to perform on fail (redirect, alert, etc.)
     }
 }
Exemple #27
0
 public function sendMail($email, $subject, $message)
 {
     $yiiMailMessage = new YiiMailMessage();
     $yiiMailMessage->setBody($message, 'text/html');
     $yiiMailMessage->subject = $subject;
     $yiiMailMessage->addTo($email);
     $yiiMailMessage->from = Yii::app()->params['adminEmail'];
     return Yii::app()->mail->send($yiiMailMessage);
     //    	$adminEmail = Yii::app()->params['adminEmail'];
     //	    $headers = "MIME-Version: 1.0\r\nFrom: $adminEmail\r\nReply-To: $adminEmail\r\nContent-Type: text/html; charset=utf-8";
     //	    $message = wordwrap($message, 70);
     //	    $message = str_replace("\n.", "\n..", $message);
     //	    return mail($email,'=?UTF-8?B?'.base64_encode($subject).'?=',$message,$headers);
 }
Exemple #28
0
 public function sendMail()
 {
     $msg = new YiiMailMessage("{$this->sender->login} приглашает вас в Закрытый Клуб Переводчиков");
     $msg->view = $this->to_id ? "reg_invite_user" : "reg_invite_new";
     $msg->from = Yii::app()->params['adminEmail'];
     $msg->addTo($this->to_email);
     $msg->setBody(array("invite" => $this), "text/html");
     return Yii::app()->mail->send($msg);
 }
Exemple #29
0
 /**
  * Отправляет почтовые уведомления о новом комментарии в посте. Вызывается из self::afterCommentAdd().
  *
  * @param Comment $comment - добавленный комментарий
  * @param Comment $parent - родительский комментарий (пустой объект, если в корень)
  */
 protected function comment_mail($comment, $parent, $debug = false)
 {
     $subj = "Комментарий в посте ";
     if ($this->title == "") {
         $subj .= "{$this->author->login} от " . Yii::app()->dateFormatter->formatDateTime($this->cdate, "medium", "short");
     } else {
         $subj = "\"{$this->title}\"";
     }
     // Шлём уведомления на почту автору поста, если это не мой пост
     if ($this->author->id != Yii::app()->user->id and $this->author->ini_get(User::INI_MAIL_COMMENTS)) {
         $msg = new YiiMailMessage($subj);
         $msg->view = "comment_post";
         $msg->setFrom(array(Yii::app()->params["commentEmail"] => Yii::app()->user->login . " - комментарий"));
         $msg->addTo($this->author->email);
         $msg->setBody(array("comment" => $comment, "post" => $this), "text/html");
         Yii::app()->mail->send($msg);
         if ($debug) {
             $debug_text = "From: " . print_r($msg->from, true) . "\nTo: " . print_r($msg->to, true) . "\nSubj: {$msg->subject}\n{$msg->body}\n\n";
             file_put_contents($_SERVER["DOCUMENT_ROOT"] . "/{$msg->view}.email.html", $debug_text);
         }
     }
     // Шлём уведомление на почту автору комментария, на который ответили, если я отвечал не себе и не автору поста (в последнем случае, он уже получил уведомление)
     if ($parent->id and $parent->author->id != Yii::app()->user->id and $parent->author->id != $this->author->id and $parent->author->ini_get(User::INI_MAIL_COMMENTS)) {
         $msg = new YiiMailMessage($subj);
         $msg->view = "comment_reply";
         $msg->setFrom(array(Yii::app()->params["commentEmail"] => Yii::app()->user->login . " - комментарий"));
         $msg->addTo($parent->author->email);
         $msg->setBody(array("comment" => $comment, "parent" => $parent, "post" => $this), "text/html");
         Yii::app()->mail->send($msg);
         if ($debug) {
             $debug_text = "From: " . print_r($msg->from, true) . "\nTo: " . print_r($msg->to, true) . "\nSubj: {$msg->subject}\n{$msg->body}\n\n";
             file_put_contents($_SERVER["DOCUMENT_ROOT"] . "/{$msg->view}.email.html", $debug_text);
         }
     }
     return true;
 }
 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));
 }