Пример #1
0
 public function contact()
 {
     $this->setTitle('Liên hệ');
     if ($this->request->is('post')) {
         $this->loadModel('Contact');
         $save_data = array('Contact' => array('name' => $this->request->data('name'), 'address' => $this->request->data('address'), 'phone' => $this->request->data('phone'), 'email' => $this->request->data('email'), 'title' => 'Liên hệ : ' . $this->request->data('name'), 'descriptions' => $this->request->data('message')));
         if ($this->Contact->save($save_data)) {
             $Email = new CakeEmail('smtp');
             $Email->emailFormat('text')->subject($save_data['Contact']['title']);
             $this->loadModel('Setting');
             $mail_lists = $this->Setting->getCacheSetting('mail_receiver');
             $mail_lists = explode(';', $mail_lists['emails']['value']);
             $mail_lists = array_filter($mail_lists);
             //                $mail_lists = Configure::read('mail_receiver');
             if ($mail_lists) {
                 $Email->to($mail_lists);
                 $content = "\nNgười gửi : {$save_data['Contact']['name']} \n\nSố điện thoại : {$save_data['Contact']['phone']} \n\nEmail : {$save_data['Contact']['email']} \n\nĐịa chỉ : {$save_data['Contact']['address']} \n\nNội dung liên hệ : {$save_data['Contact']['descriptions']}\n\n\n\n                    ";
                 $Email->send($content);
             }
             echo json_encode(array('status' => 'ok', 'messages' => array('Cảm ơn bạn đã quan tâm đến BIOWAY-HITECH <br>Chúng tôi sẽ liên lạc lại bạn trong thời gian sớm nhất')));
             die;
         } else {
             echo 'ng';
             die;
         }
     }
 }
Пример #2
0
 /**
  * Send mail
  *
  * @param CakeEmail $email CakeEmail
  * @return array
  */
 public function send(CakeEmail $email)
 {
     $headers = $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject'));
     $headers = $this->_headersToString($headers);
     $message = implode("\r\n", (array) $email->message());
     return array('headers' => $headers, 'message' => $message);
 }
Пример #3
0
 public function sendPassword($emailLog)
 {
     $searchPlayer = "Select email From players As Player Where email = '";
     $searchPlayer .= $emailLog;
     $searchPlayer .= "'";
     if (!$this->query($searchPlayer)) {
         return false;
     } else {
         /*
          * renvoie un pass chiffré. PAS BON !!
          * renvoyer un mot de pass par défault
          * rediriger vers la page change password
          * faire comme si on changeait le mdp
          */
         $tempPass = $this->generatePassword();
         $tempPassCrypted = Security::hash($tempPass);
         $updatePass = "******" . $tempPassCrypted . "' Where email = '" . $emailLog . "'";
         $this->query($updatePass);
         //@todo: sauvegarder dans la base
         $message = "Voici votre mot de passe temporaire. Connectez-vous avec pour le changer.";
         App::uses('CakeEmail', 'Network/Email');
         $mail = new CakeEmail('rox');
         $mail->to($emailLog)->subject('WebArena Information')->template('player')->viewVars(array('message' => $message, 'email' => $emailLog, 'password' => $tempPass))->emailFormat('html');
         return $mail->send();
     }
 }
Пример #4
0
 /**
  * Выдает информацию о пользователе
  *
  * @param array $data
  * @return array
  */
 public function register($data)
 {
     if ($data['full_name']) {
         if (isset($data['surname']) and $data['surname']) {
             $data['full_name'] = $data['full_name'] . ' ' . $data['surname'];
         }
     } else {
         list($userName) = explode('@', $data['username']);
         $data['full_name'] = $userName;
     }
     unset($data['surname']);
     $this->User->set($data);
     if (!$this->User->validates()) {
         throw new ApiIncorrectRequestException($this->User->validationErrors);
     }
     if (!in_array($data['lang'], array('eng', 'rus'))) {
         $errors = array('lang' => array('Incorrect Lang'));
         throw new ApiIncorrectRequestException($errors);
     }
     if ($this->User->save($data)) {
         $user = $this->User->findByUsername($data['username']);
         $userId = Hash::get($user, 'User.id');
         $userName = Hash::get($user, 'User.full_name');
         $userMail = Hash::get($user, 'User.username');
         $pass = substr($user['User']['password'], 0, 5);
         $pass = md5('iP5UxZWIbVJ1XJIW' . $pass);
         $Email = new CakeEmail();
         $Email->template('reg_confirm', 'mail')->viewVars(array('userId' => $userId, 'userName' => $userName, 'userMail' => $userMail, 'token' => $pass))->emailFormat('html')->from('*****@*****.**')->to($data['username'])->subject('Verify registration on Konstruktor.com')->send();
         return $userId;
     } else {
         throw new Exception('Registration Error');
     }
 }
Пример #5
0
 /**
  * メール送信処理
  */
 public function sendEmail($to, $subject, $template, $body = null)
 {
     // メールライブラリ読み込み
     App::uses('CakeEmail', 'Network/Email');
     $email = new CakeEmail();
     $res = $email->config(array('log' => 'emails'))->template($template, 'default')->viewVars($body)->from(array('*****@*****.**' => __('iPost Enterprise運営事務局')))->to($to)->subject($subject)->send();
 }
Пример #6
0
    public function send() {         
        ini_set('max_execution_time', 0);
        $test = array(
           array('User' => array('email' =>'*****@*****.**'))
        );
        $this->User->unbindAll();
        $users = $this->User->find('all', array('fields' => array('email'), 'conditions' => array('email not like "%@facebook.com%"'), 'order' => array('id DESC')));
        $count = 1;
        foreach ($users as $user) {
            if (!empty($user['User']['email'])) {
                $count++;
                try {                    
                    $email = new CakeEmail('stars');                       
                    $email->template('open')
                    ->emailFormat('html')
                    ->from(array('*****@*****.**' => '5Stars MobileGames Ltd'))
                    ->to($user['User']['email'])
                    //->bcc(array('*****@*****.**'))
                    ->subject('Mỹ Hầu Vương | Tri ân người chơi tặng Gift code 500k nhân ngày Openbeta')
                    ->send();           

                    echo $count.' sent to '.$user['User']['email'].' waiting  10 sec...'. "\n";
                    
                    
                    sleep(1); 
                } catch(Exception $e) {
                    echo $e->getMessage();
                    echo $count.'cannot send to '.$user['User']['email']. "\n";
                }   
            }
        }  
    }
 private function _sendPart()
 {
     if (empty($this->_recipients)) {
         return true;
     }
     $json = array('to' => $this->_getAddress(array_splice($this->_recipients, 0, $this->_config['count'])), 'category' => !empty($this->_headers['X-Category']) ? $this->_headers['X-Category'] : $this->_config['category']);
     //Sendgrid Substitution Tags
     if (!empty($this->_headers['X-Sub'])) {
         foreach ($this->_headers['X-Sub'] as $key => $value) {
             $json['sub'][$key] = array_splice($value, 0, $this->_config['count']);
         }
     }
     $params = array('api_user' => $this->_config['username'], 'api_key' => $this->_config['password'], 'x-smtpapi' => json_encode($json), 'to' => '*****@*****.**', 'subject' => $this->_cakeEmail->subject(), 'html' => $this->_cakeEmail->message('html'), 'text' => $this->_cakeEmail->message('text'), 'from' => $this->_config['from'], 'fromname' => $this->_config['fromName'], 'replyto' => array_keys($this->_replyTo)[0]);
     $attachments = $this->_cakeEmail->attachments();
     if (!empty($attachments)) {
         foreach ($attachments as $key => $value) {
             $params['files[' . $key . ']'] = '@' . $value['file'];
         }
     }
     $result = json_decode($this->_exec($params));
     if ($result->message != 'success') {
         return $result;
     } else {
         return $this->_sendPart();
     }
 }
 public function index()
 {
     //checking session
     $uid = $this->Session->read('Auth.User.id');
     if (isset($uid)) {
         return $this->redirect(array('controller' => 'profiles', 'action' => 'edit'));
     }
     $this->layout = 'main';
     $title = 'User Registration';
     $this->set(compact('title'));
     //check from submit or not
     if ($this->request->is('post')) {
         //uploading image file
         $new_file_name = rand(1000, rand(100000, rand(1000000, 10000000))) . "_" . md5(time()) . "_" . time() . $this->data['Profile']['image']['name'];
         move_uploaded_file($this->data['Profile']['image']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/registration/app/webroot/img/image/' . $new_file_name);
         $this->request->data['Profile']['image'] = '/registration/app/webroot/img/image/' . $new_file_name;
         //----------------------
         //save data
         if ($this->Profile->save($this->request->data)) {
             $Email = new CakeEmail();
             $Email->from(array('*****@*****.**' => 'Cake registration demo'));
             $Email->to($this->data['Profile']['email']);
             $Email->subject('Registration process completed successfully');
             $Email->send('Welcome to cake registration demo .Your registration process completed successfully');
             $this->Session->setFlash('User details has been saved.', 'default', array('class' => 'alert alert-success'));
             return $this->redirect(array('action' => 'login'));
         }
         //------------
         //on failure
         $this->Session->setFlash('Unable to add User details.', 'default', array('class' => 'alert alert-danger'));
     }
 }
Пример #9
0
 public function send()
 {
     if ($this->request->is('post')) {
         // Check security token
         if (empty($this->request->data['Feedback']['token']) || $this->request->data['Feedback']['token'] != '!pilule$') {
             throw new NotFoundException();
         }
         // Send feedback via email
         $Email = new CakeEmail();
         if (!empty($this->request->data['Feedback']['name']) && !empty($this->request->data['Feedback']['email'])) {
             $Email->replyTo(array($this->request->data['Feedback']['email'] => $this->request->data['Feedback']['name']));
         }
         $Email->from('*****@*****.**');
         $Email->to('*****@*****.**');
         $Email->config('postmark');
         $Email->subject('Pilule - Commentaires');
         $Email->template('feedback');
         $Email->emailFormat('html');
         $Email->viewVars(array('message' => $this->request->data));
         if ($Email->send()) {
             return new CakeResponse(array('body' => json_encode(array('status' => true))));
         } else {
             return new CakeResponse(array('body' => json_encode(array('status' => false))));
         }
     } elseif ($this->request->is('ajax')) {
         $this->layout = 'ajax';
         $this->render('modals/form');
     }
 }
Пример #10
0
 public function forget()
 {
     if ($this->request->is('post')) {
         $error = null;
         $email = $this->request->data['User']['email'];
         $result = $this->User->find('first', array('conditions' => array('User.email' => $email)));
         if ($result == null || empty($result)) {
             $error = "メールアドレスが登録されていません。";
         } else {
             $host = empty($_SERVER['CAKE_ENV']) ? 'localhost' : $_SERVER['CAKE_ENV'];
             $pre_id = $result['User']['pre_id'];
             $gmail = new CakeEmail('gmail');
             $gmail->to($email);
             $gmail->subject('seapaパスワード再設定URL');
             $messages = $gmail->send('パスワード再設定URL : http://' . $host . '/regist/reinput?pre_id=' . $pre_id);
             if ($messages == null) {
                 $error = "メールが送信できませんでした。管理者にお問い合わせください。";
             }
         }
         if (empty($error)) {
             $this->redirect(array('controller' => 'preregist', 'action' => 'result'));
         } else {
             $this->Session->setFlash($error, "flash_error");
         }
     }
 }
Пример #11
0
 protected function sendEmail($address, $username, $pass)
 {
     $subject = 'You now are an user of Employees Directory!';
     $body = 'Your username : '******'. Your password : '******'. (not include the last period)';
     $email = new CakeEmail('smtp');
     $email->to($address)->subject($subject)->send($body);
 }
Пример #12
0
 /**
  * Find a potential queue and if found, send each email one by one
  *
  * @return void
  */
 public function run()
 {
     // The consumer ID will be placed against all pending emails
     $consumerId = uniqid();
     // Inform the user of the consumer id before proceeding
     $this->_renderHeader();
     $this->out("   Consumer ID: {$consumerId}", 2);
     // Search for pending emails and apply the consumer id to them
     if (!$this->EmailQueue->updatePending($consumerId)) {
         return $this->out('   Found 0 items in queue, exiting ...', 2);
     }
     // Find all the emails which were assigned with the consumer id
     $pendingItems = $this->EmailQueue->pendingItems($consumerId);
     $this->out('   Found ' . count($pendingItems) . ' items in queue, dispatching:', 2);
     // Loop through each email one by one
     foreach ($pendingItems as $item) {
         // Inform the user which email is being processed currency
         $this->out('    ' . str_pad("# {$item['EmailQueue']['id']}", 7, ' ') . '  ' . str_pad($item['EmailQueue']['to'] . '  ', 40, '.'), false);
         // Use your preferred email config here
         $email = new CakeEmail('custom');
         // Attempt to send the serialized email using the above config, log the status
         if ($email->transportClass()->send(unserialize($item['EmailQueue']['serialized']))) {
             $status = 1;
             $this->out('  [<success> OK </success>]', 2);
         } else {
             $status = 2;
             $this->out('  [<warning> !! </warning>]', 2);
         }
         // Attempt to update the email queue record with the new status
         if (!$this->EmailQueue->saveItemStatus($item['EmailQueue']['id'], $status)) {
             throw new Exception("Saving queue item failed, orphan created for ID #{$item['EmailQueue']['id']}!");
         }
     }
 }
Пример #13
0
 public function individualMail($section, $arr = array())
 {
     $this->autoRender = false;
     $contents = $this->Mail->findBySection($section);
     $content = $contents['Mail']['content'];
     foreach ($arr as $key => $val) {
         $content = str_replace("~~{$key}~~", $val, $content);
     }
     if (!empty($arr['TO_EMAIL']) && Validation::email($arr['TO_EMAIL'], true)) {
         $email = new CakeEmail();
         $email->template('default');
         $email->config('default');
         $email->emailFormat('html')->to($arr['TO_EMAIL'])->subject($contents['Mail']['subject']);
         try {
             if ($email->send($content)) {
                 return;
             } else {
                 return;
             }
         } catch (Exception $e) {
             return;
         }
     }
     return;
 }
Пример #14
0
 protected function _sendEmail()
 {
     App::uses('CakeEmail', 'Network/Email');
     $Email = new CakeEmail();
     $Email->emailFormat('text')->template('new_user', 'default')->from(Configure::read('Site.email_from'))->replyTo($this->request->data['Contact']['email'])->subject('EU-GENIE Contact Form')->to(Configure::read('Site.email_to'));
     $Email->send();
 }
Пример #15
0
 public function contactus()
 {
     if ($this->request->data) {
         $this->request->data['Contact'] = Sanitize::clean($this->request->data, array("remove_html" => TRUE));
         $cakeEmail = new CakeEmail('default');
         if ($this->request->data['Contact']['emailbool'] == "2") {
             $email_to = Configure::read('Config.general');
             $cakeEmail->template('enquiry', 'default')->emailFormat('html')->to($email_to)->subject('HaRiMau - General Enquiry');
         } else {
             $email_to = Configure::read('Config.business');
             $cakeEmail->template('enquiry', 'default')->emailFormat('html')->to($email_to)->subject('HaRiMau - Business Enquiry');
         }
         $cakeEmail->viewVars(array('user' => $this->request->data));
         if ($cakeEmail->send()) {
             $cnt_data = $this->Notification->find('count', array('conditions' => array('markas' => 'Unread', 'type' => 'Contact')));
             $arr['Notification']['type'] = 'Contact';
             $arr['Notification']['status'] = 'Approve';
             $arr['Notification']['count'] = $cnt_data + 1;
             $arr['Notification']['markas'] = 'Unread';
             $arr['Notification']['bell'] = 'On';
             $noti = $this->Notification->save($arr);
             $noti_data = $this->Notification->find('all', array('conditions' => array('markas' => 'Unread')));
             $numNoti = count($noti_data);
             $this->set('count', $numNoti);
             $this->Session->setFlash('<div class="alert alert-success"><i class="fa fa-check-circle"></i> An email with details is sent to system admin as earliest as will replied you. <button data-dismiss="alert" class="close" type="button">×</button> </div>');
             //$this->Session->setFlash(__('An email with details is sent to system admin as earliest as will replied you. '));
         } else {
             $this->Session->setFlash('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> Problem on sending email to enquiry department. Please contact to administrator.<button data-dismiss="alert" class="close" type="button">×</button> </div>');
             //$this->Session->setFlash(__('Problem on sending email to enquiry department. Please contact to administrator'));
         }
     } else {
         $this->set('count', 0);
     }
 }
Пример #16
0
 public function preview($e)
 {
     $configName = $e['EmailQueue']['config'];
     $template = $e['EmailQueue']['template'];
     $layout = $e['EmailQueue']['layout'];
     $headers = empty($e['EmailQueue']['headers']) ? array() : (array) $e['EmailQueue']['headers'];
     $theme = empty($e['EmailQueue']['theme']) ? null : (string) $e['EmailQueue']['theme'];
     if (empty($theme)) {
         $theme = '';
     }
     $email = new CakeEmail($configName);
     $email->transport('Debug')->to($e['EmailQueue']['to'])->subject($e['EmailQueue']['subject'])->template($template, $layout)->emailFormat($e['EmailQueue']['format'])->addHeaders($headers)->theme($theme)->messageId(false)->returnPath($email->from())->viewVars($e['EmailQueue']['template_vars']);
     $return = $email->send();
     $this->out('Content:');
     $this->hr();
     $this->out($return['message']);
     $this->hr();
     $this->out('Headers:');
     $this->hr();
     $this->out($return['headers']);
     $this->hr();
     $this->out('Data:');
     $this->hr();
     debug($e['EmailQueue']['template_vars']);
     $this->hr();
     $this->out();
 }
 /**
  * Mark Complete method - Sets Risk Asessment to complete in the Clients Model
  *
  */
 public function mark_complete()
 {
     $completed = date('Y-m-d');
     // Get DateTime
     $client = $this->Session->read('Auth.User.client_id');
     $clientName = $this->Session->read('Auth.User.Client.name');
     $this->loadModel('Client');
     $this->Client->id = $client;
     $this->render(false);
     // tell cake to not use a view
     $existing_completion_date = $this->Client->field('risk_assessment_status');
     if ($existing_completion_date != '') {
         $this->Session->setFlash(__('Your Risk Assessment was already marked complete on ') . $existing_completion_date . '.');
         $this->redirect(array('action' => 'index'));
         return;
     }
     // Send Email
     $message = 'New Risk Assessment Completed by Client ' . $clientName . ' - Completed on ' . $completed;
     $email = new CakeEmail('hipaaMail');
     $email->to(Configure::read('App.adminEmailTo'))->subject('HIPAA Risk Assessment Marked Complete by Client - ' . $clientName)->send($message);
     if ($this->Client->saveField('risk_assessment_status', $completed)) {
         $this->Session->setFlash('Thanks! Your Risk Assessment has been marked complete.', 'default', array('class' => 'success message'));
         $this->redirect(array('controller' => 'dashboard', 'action' => 'index'));
     } else {
         $this->Session->setFlash(__('Sorry, Risk Assessment did not complete. Please, try again.'));
         $this->redirect(array('controller' => 'dashboard', 'action' => 'index'));
     }
 }
Пример #18
0
 /**
      Sender purringer til alle som har vært forfalt og ikke purret i minst to uker
      
      Sender melding til alle som har vært forfalt i mindre enn to uker, og ikke allerede har fått melding
   **/
 function autopurr()
 {
     $purret = array();
     $meldt = array();
     $feil = array();
     foreach ($this->PurreFaktura->find('list', array('fields' => 'faktura_id')) as $faktura) {
         if ($this->Purring->epostPurring($faktura, 'purring')) {
             $purret[] = $faktura;
         } else {
             $feil[] = $faktura;
         }
     }
     /*
       foreach($this->MeldeFaktura->find('list', array('fields'=>'faktura_id')) as $faktura){
       if($this->Purring->epostPurring($faktura, 'faktura_melding'))
       $meldt[] = $faktura;
       else
       $feil[] = $faktura;
       }
     */
     if (count($purret) > 0) {
         $logg_mail = new CakeEmail('default');
         $logg_mail->to("*****@*****.**")->subject("Automatisk utførte purringar")->template('autopurr_logg', 'vanlig')->emailFormat('html')->viewVars(array('purret' => $purret, 'navn' => 'Purrere i Zapatistgruppa', 'epost' => '', 'feil' => $feil))->send();
     }
     return;
 }
    function email_referrer($receiver = null, $invite_total = null, $code = null)
    {
        $share_link = FULL_BASE_URL . '/invite/' . $code;
        //For our coming soon incentive, we were increasing peoples call rates by 10 cents for every person that joined the site from their link
        //so the funciton below simply calculates their new rate.
        //add in your own function if you want
        $total_referrals = $invite_total;
        $current_rate = 2.5 + $invite_total * 0.1;
        if ($current_rate > 3.5) {
            $current_rate = 3.5;
        }
        $message = 'Nice work!  
								<br /><br />
							One of your friends just joined Amplifyd.  Your new caller rate is now $' . $current_rate . '0/per call. 
								<br /><br />
							Because of you, our public voice just got stronger and louder.
								<br /><br />
							Keep it up, here\'s your unique invite link again: 
								<br />
							<a href="' . $share_link . '" >' . $share_link . '</a>
								<br /><br />
							';
        $email = new CakeEmail('sendgrid');
        $email->emailFormat('html');
        $email->to($receiver);
        $email->subject('A Friend Just Joined');
        $email->send($message);
    }
Пример #20
0
 public function sendEmail($event)
 {
     $user_email = $event->subject()->data['User']['email'];
     App::uses('CakeEmail', 'Network/Email');
     $email = new CakeEmail('default');
     $email->to($user_email)->subject(__('Welcome on Sonerezh !'))->emailFormat('html')->template('userAdd')->send();
 }
 public function index()
 {
     if (!$this->request->data) {
         $this->render();
         return;
     }
     $this->User->validate = array('email' => array(array('rule' => 'notEmpty', 'message' => 'メールアドレスを入力してください'), array('rule' => array('custom', '/^.+@.+$/'), 'message' => 'メールアドレスの形式が正しくありません。'), array('rule' => 'confirm', 'message' => 'メールアドレスが一致していません。'), array('rule' => 'isUniqueAndActive', 'message' => 'このメールアドレスは使用されています。')));
     $this->User->set($this->request->data);
     if (!$this->User->invalidFields()) {
         $email = $this->request->data['User']['email'];
         $activation_code = md5($email . time());
         $user = $this->User->find('first', array('conditions' => array('email' => $email, 'is_active' => false)));
         if (!$user) {
             $this->User->create();
             $user = array('User' => $this->request->data['User']);
         }
         $user['User']['is_active'] = false;
         $user['User']['activation_code'] = $activation_code;
         $this->User->save($user);
         $cakeemail = new CakeEmail('default');
         $cakeemail->to($email);
         $cakeemail->subject('仮登録のお知らせ');
         $cakeemail->send(sprintf('http://example.com/signup/activate/%s', $activation_code));
         $this->render('email_sent');
     }
 }
Пример #22
0
 public function mailer()
 {
     $this->loadModel('User');
     // Check the action is being invoked by the cron dispatcher
     if (!defined('CRON_DISPATCHER')) {
         $this->redirect('/Mytime');
         exit;
     }
     //no view
     //$this->autoRender = false;
     $this->layout = 'ajax';
     $aUser = $this->User->find('all');
     foreach ($aUser as $user) {
         $currTime = time();
         $lastTime = strtotime(Hash::get($user, 'User.last_update'));
         $id = $user['User']['id'];
         $date1 = $lastTime > $currTime - 43200 ? date("Y-m-d H:i:s", $lastTime) : date("Y-m-d H:00:00", $currTime - 43200);
         $date2 = date("Y-m-d H:00:00", $currTime);
         $data = $this->User->getTimeline($id, $date1, $date2, 0, true);
         $this->set('data', $data);
         $this->set('timeFrom', strtotime($date1));
         $this->set('timeTo', strtotime($date2));
         if (count($data['events'])) {
             $Email = new CakeEmail('postmark');
             $Email->template('updates_mailer', 'mail')->viewVars(array('data' => $this->User->getTimeline($id, $date1, $date2, 0), 'timeFrom' => strtotime($date1), 'timeTo' => strtotime($date2)))->to(Hash::get($user, 'User.username'))->subject('Last updates on Konstruktor.com')->send();
         }
     }
     return;
 }
Пример #23
0
 public function login()
 {
     if ($this->request->is('post')) {
         if ($this->Auth->login()) {
             /* ログイン時に定期バックアップを判定して作成ここから */
             $file_pass = '******';
             $file_name = 'sister_backup';
             $backup_flg = 1;
             $folder = new Folder($file_pass);
             $lists = $folder->read();
             foreach ($lists[1] as $list) {
                 //ファイル名から日付を取得
                 $name = str_replace(array($file_name . '_', '.txt'), '', $list);
                 if (date('Ymd', strtotime('-7 day')) < date($name)) {
                     //直近のファイルがあればflgを消去
                     $backup_flg = 0;
                     break;
                 }
             }
             if ($backup_flg == 1) {
                 //flgがあればバックアップを作成
                 //DBデータを取得する
                 $array_model = array('Administrator', 'Banner', 'Birthday', 'Diary', 'DiaryGenre', 'Game', 'Information', 'Link', 'Maker', 'Music', 'Photo', 'Product', 'SisterComment', 'Voice');
                 foreach ($array_model as $model) {
                     $this->{$model}->Behaviors->disable('SoftDelete');
                     $datas = $this->{$model}->find('all', array('order' => $model . '.id', 'recursive' => -1));
                     $this->set($model . '_datas', $datas);
                     $this->set($model . '_tbl', $this->{$model}->useTable);
                 }
                 $this->set('array_model', $array_model);
                 $this->layout = false;
                 $sql = $this->render('sql_backup');
                 $file = new File($file_pass . '/' . $file_name . '_' . date('Ymd') . '.sql', true);
                 if ($file->write($sql)) {
                     //バックアップ成功時の処理
                     $file->close();
                     foreach ($lists[1] as $list) {
                         $file = new File($file_pass . '/' . $list);
                         $file->delete();
                         $file->close();
                     }
                 } else {
                     //バックアップ失敗時の処理
                     $file->close();
                     $admin_mail = Configure::read('admin_mail');
                     $email = new CakeEmail('gmail');
                     $email->to($admin_mail)->subject('【虹妹prprシステム通知】バックアップエラー通知')->template('backup_error', 'sister_mail')->viewVars(array('name' => '管理者'));
                     //mailに渡す変数
                     $email->send();
                 }
             }
             /* ログイン時に定期バックアップを判定して作成ここまで */
             $this->redirect($this->Auth->redirect());
         } else {
             $this->Flash->error(__('ユーザ名かパスワードが間違っています。'));
             $this->redirect('/login/');
         }
     }
 }
Пример #24
0
 private function __sendEmail($data = array())
 {
     $this->autoRender = false;
     $email = new CakeEmail('default');
     $email->viewVars($data);
     $email->template('contact')->emailFormat('html')->to($data['email'])->cc($data['cc'])->subject('【ご意見番】 お問い合わせ');
     $email->send();
 }
Пример #25
0
 protected function addAttachments(CakeEmail $email)
 {
     $attachments = $email->attachments();
     $this->data['attachments'] = array();
     foreach ($attachments as $filename => $data) {
         $this->data['attachments'][] = array('filename' => $filename, 'content' => file_get_contents($data['file']));
     }
 }
Пример #26
0
 private function sendUserCreatedMail($id, $plainPwd = null)
 {
     $mail = new CakeEmail('smtp');
     $options = array('conditions' => array('User.' . $this->User->primaryKey => $id));
     $res = $this->User->find('first', $options);
     $mail->viewVars(array('user' => $res, 'plainPwd' => $plainPwd));
     $mail->template('user_created')->emailFormat('html')->to($res['User']['email'])->subject("Registro de usuario")->send();
 }
 function email_adminOut($task = null, $message)
 {
     $email = new CakeEmail('sendgrid');
     $email->emailFormat('html');
     $email->to(Configure::read('Admin.admin_email'));
     $email->subject('[' . $task . '] shell completion status');
     $email->send($message);
 }
 /**
  * add method
  *
  * @return void
  */
 public function email($id)
 {
     App::uses('CakeEmail', 'Network/Email');
     $Email = new CakeEmail();
     $name1 = $this->QualityReport->findById($id);
     $Email->from(array('*****@*****.**' => '*****@*****.**'))->to($name1['QualityReport']['to'])->subject($name1['QualityReport']['subject'])->send($name1['QualityReport']['content']);
     $this->Session->setFlash(__('Email has been sent'));
     return $this->redirect(array('action' => 'index'));
 }
 public function execute()
 {
     if (empty($this->args[0]) || empty($this->args[1])) {
         throw new MailqueueArgumentException('Rquired arguments "queue-name", "transport configuration name"');
     }
     $queueMailer = new CakeEmail($this->args[0]);
     $realMailer = new CakeEmail(empty($this->args[1]) ? null : $this->args[1]);
     $queueMailer->transportClass()->flush($realMailer);
 }
Пример #30
0
 private function _sendEmail($arr = array())
 {
     $sender = Configure::read('Settings.Accounting.accounting_email') == '' ? '*****@*****.**' : Configure::read('Settings.Accounting.accounting_email');
     $email_options = array('sender' => array($sender => PAGE_NAME), 'from' => array($sender => PAGE_NAME), 'to' => array($sender), 'subject' => __('Ratecard change information'), 'viewVars' => array('content' => ''), 'template' => 'default', 'layout' => 'default');
     $options = array_merge($email_options, $arr);
     $email = new CakeEmail($options);
     $email->emailFormat('html');
     return $email->send();
 }