コード例 #1
0
ファイル: SiteController.php プロジェクト: Gnafu/wiz
 public function actionFeedback()
 {
     if (isset($_POST)) {
         //send e-mail to administrator
         Yii::app()->mailer->AddAddress(Yii::app()->params['adminEmail']);
         Yii::app()->mailer->Subject = 'Feedback Wiz';
         $note = $_POST['note'];
         if (empty($note)) {
             $note = "No notes posted.";
         }
         $content = "<table cellspacing=\"10px\" cellpadding=\"10px\"><tr><td style=\"font-weight:bold\" align=\"right\">User Agent</td><td>" . Yii::app()->browser->getUserAgent() . "</td><tr><td style=\"font-weight:bold\" align=\"right\">User Note</td><td style=\"font-style:italic\">" . $note . "</td></tr>";
         try {
             $filename = Yii::app()->basePath . '/../screenshot/' . $_POST['screenshot'] . '.png';
             if (file_exists($filename)) {
                 Yii::app()->mailer->AddAttach($filename);
             }
             Yii::app()->mailer->MsgHTML($content);
             $result = Yii::app()->mailer->Send($content);
         } catch (Exception $e) {
             //logs send failure
             $result = 'error';
             $logs = new SendmailLogs();
             $logs->attributes = array('mail_type' => 'feedback', 'mail_identifier' => 0, 'error_code' => $e->getCode(), 'error_message' => $e->getMessage(), 'address' => Yii::app()->params['adminEmail']);
             $logs->save();
         }
         echo $result;
     }
 }
コード例 #2
0
ファイル: Notifications.php プロジェクト: Gnafu/wiz
 /**
  * Sends an email to users who want to receive a notification
  * if their role corresponds to that associated with the notification.
  */
 public function afterSave()
 {
     //checks if send_mail==true and if the variable Yii::app()->params['block_email'] is set to true to inhibit the delivery of mail
     if ($this->send_mail && !Yii::app()->params['block_email']) {
         $mail_identifier = $this->primaryKey;
         if ($this->category->role_name == 'owner') {
             $users = Users::model()->findAll('username=:username', array(':username' => $this->owner));
         } else {
             $users = Users::model()->findAll('role_name=:role_name', array(':role_name' => $this->category->role_name));
         }
         $send = false;
         $recipients = null;
         foreach ($users as $user) {
             $settings = Settings::model()->findByPk(array('username' => $user->username, 'notification_category_ptr' => $this->notification_category_ptr));
             if ($settings == NULL) {
                 //note: if settings is null the email sendign is enable!
                 Yii::app()->mailer->AddAddress($user->email);
                 $recipients .= $user->email . ",";
                 $send = true;
             }
         }
         if ($send || Yii::app()->params['debug_email']) {
             //checks if email debugging is active
             if (Yii::app()->params['debug_email']) {
                 $this->mail_subject = "[ WIZ DEBUG EMAIL ] " . $this->mail_subject;
                 $this->mail_body = "[ REAL RECIPIENTS ] => [ " . $recipients . " ]<br/><br/> " . $this->mail_body;
                 Yii::app()->mailer->ClearAddresses();
                 Yii::app()->mailer->AddAddress(Yii::app()->params['debugEmail']);
             }
             try {
                 Yii::app()->mailer->Subject = $this->mail_subject;
                 $footer_text = 'THIS IS AN AUTOMATIC MESSAGE, PLEASE DO NOT RESPOND';
                 $wiz_logo = 'wizlogo.png';
                 $tree_logo = 'ambiente_logo.gif';
                 $html_msg = '<html>' . ' <head></head>' . ' <body>' . '  <table style="width: 100%; border-bottom: solid 2px #006AB2;">' . '   <tr>' . '    <td align="left"> <img src="' . Yii::app()->getBaseUrl(true) . '/images/' . $wiz_logo . '" height="70" width="74"/></td>' . '   </tr>' . '  </table>' . '  <br/>' . '  <table style="width: 100%; border-bottom: solid 2px #006AB2;">' . '   <tr>' . '    <td align="left"> ' . $this->mail_body . '</td>' . '   </tr>' . '   <tr>' . '    <td align="left"> &nbsp; </td>' . '   </tr>' . '  </table>' . '  <table style="width: 100%;">' . '   <tr>' . '    <td align="left"> <img src="' . Yii::app()->getBaseUrl(true) . '/images/' . $tree_logo . '" height="86" width="286"/></td>' . '   </tr>' . '   <tr>' . '    <td align="left"> ' . $footer_text . '</td>' . '   </tr>' . '  </table>' . ' </body>' . '</html>';
                 Yii::app()->mailer->MsgHTML($html_msg);
                 Yii::app()->mailer->Send();
             } catch (Exception $e) {
                 //logs send failure
                 $logs = new SendmailLogs();
                 $logs->attributes = array('mail_type' => 'notifications', 'mail_identifier' => $mail_identifier, 'error_code' => $e->getCode(), 'error_message' => $e->getMessage(), 'address' => $user->email);
                 $logs->save();
             }
         }
     }
 }