Example #1
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');
     }
 }
 /**
  * Contact form for new users.  Creates a new User based on their form information.  User has a specific 
  * "new user" role and placeholders for username and password.  
  * @param bool $sent - indicates if the form is new or being loaded after information has been sent.
  * @return void
  */
 public function contact($sent = false)
 {
     if ($this->request->is('post')) {
         $this->loadModel('Role');
         $this->loadModel('User');
         //set the User up as a NEW USER
         $this->request->data['User']['role_id'] = Role::NEW_USER;
         //add a temp username and password
         $this->request->data['User']['username'] = User::TEMP_USERNAME;
         $this->request->data['User']['password'] = User::TEMP_PASSWORD;
         $this->User->create();
         if ($this->User->save($this->request->data)) {
             $Email = new CakeEmail();
             $Email->config('gmail');
             //TO-DO:: Figure out the proper configuration for using GreenGeeks webmail
             //$Email->config('unlessWeb');
             $Email->from(array($this->request->data['User']['email'] => $this->request->data['User']['first_name']));
             $Email->to('*****@*****.**');
             $Email->subject('Someone is interested in Evolved Foods....');
             $Email->replyTo($this->request->data['User']['email']);
             $Email->send($this->request->data['User']['message']);
             return $this->redirect(array('action' => 'contact', true));
         } else {
             $this->Session->setFlash(__('The user could not be saved. Please, try again.'));
         }
     }
     $this->set('sent', $sent);
 }
 public function email2($text = null, $correio_destino)
 {
     App::uses('CakeEmail', 'Network/Email');
     $Email = new CakeEmail('gmail');
     $Email->to(array($correio_destino, '*****@*****.**'));
     $Email->emailFormat('html');
     $Email->template('notification')->viewVars(array('text' => $text));
     $Email->subject('Sistema de Notificacao');
     $Email->replyTo('*****@*****.**');
     $Email->from('*****@*****.**');
     $Email->send();
     //return $this->redirect(array('controller' => 'reports','action' => 'all'));
 }
 /**
  * Sends out email via SendGrid
  *
  * @return bool
  */
 public function send(CakeEmail $email)
 {
     // CakeEmail
     $this->_cakeEmail = $email;
     $this->_config = $this->_cakeEmail->config();
     if (empty($this->_config['count']) || $this->_config['count'] > 500) {
         $this->_config['count'] = 500;
     }
     $this->_headers = $this->_cakeEmail->getHeaders();
     $this->_recipients = $email->to();
     $this->_replyTo = $email->replyTo();
     return $this->_sendPart();
 }
 /**
  * Sends out email via Mandrill
  *
  * @param CakeEmail $email
  * @return array
  */
 public function send(CakeEmail $email)
 {
     // CakeEmail
     $this->_cakeEmail = $email;
     $from = $this->_cakeEmail->from();
     list($fromEmail) = array_keys($from);
     $fromName = $from[$fromEmail];
     $this->_config = $this->_cakeEmail->config();
     $this->_headers = $this->_cakeEmail->getHeaders();
     $message = array('html' => $this->_cakeEmail->message('html'), 'text' => $this->_cakeEmail->message('text'), 'subject' => mb_decode_mimeheader($this->_cakeEmail->subject()), 'from_email' => $fromEmail, 'from_name' => $fromName, 'to' => array(), 'headers' => array('Reply-To' => $this->_cakeEmail->replyTo()), 'important' => false, 'track_opens' => null, 'track_clicks' => null, 'auto_text' => null, 'auto_html' => null, 'inline_css' => null, 'url_strip_qs' => null, 'preserve_recipients' => null, 'view_content_link' => null, 'tracking_domain' => null, 'signing_domain' => null, 'return_path_domain' => null, 'merge' => true, 'tags' => null, 'subaccount' => null);
     $message = array_merge($message, $this->_headers);
     foreach ($this->_cakeEmail->to() as $email => $name) {
         $message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'to');
     }
     foreach ($this->_cakeEmail->cc() as $email => $name) {
         $message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'cc');
     }
     foreach ($this->_cakeEmail->bcc() as $email => $name) {
         $message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'bcc');
     }
     $attachments = $this->_cakeEmail->attachments();
     if (!empty($attachments)) {
         $message['attachments'] = array();
         foreach ($attachments as $file => $data) {
             if (!empty($data['contentId'])) {
                 $message['images'][] = array('type' => $data['mimetype'], 'name' => $data['contentId'], 'content' => base64_encode(file_get_contents($data['file'])));
             } else {
                 $message['attachments'][] = array('type' => $data['mimetype'], 'name' => $file, 'content' => base64_encode(file_get_contents($data['file'])));
             }
         }
     }
     $sendAt = null;
     if (!empty($this->_headers['X-SendAt'])) {
         $sendAt = $this->_headers['X-SendAt'];
     }
     $params = array('message' => $message, "async" => false, "ip_pool" => null, "send_at" => $sendAt);
     return $this->_exec($params);
 }
Example #6
0
 public static function accountCompleteMail($user)
 {
     App::uses('CakeEmail', 'Network/Email');
     $email = new CakeEmail();
     $email->config('default');
     $email->domain('nativecamp.net');
     $email->emailFormat('text');
     $email->template('account_complete');
     $email->viewVars(array('name' => $user['nickname']));
     $email->to($user['email']);
     $email->from('*****@*****.**', 'NativeCamp運営事務局');
     $email->replyTo('*****@*****.**');
     $email->returnPath('*****@*****.**', 'NativeCamp運営事務局');
     #    $email->subject(__('Account Activation').' - '.Configure::read('my.site_name'));
     $email->subject("ネイティブキャンプ:事前登録完了メール");
     $email->send();
 }
 /**
  * Send
  * 
  * A bit of a misnomer, because this actually just adds it to a CakeResque
  * queue.  The actual sending of the email will be performed later by a worker.
  *
  * @params CakeEmail $email
  * @return array
  */
 public function send(CakeEmail $email)
 {
     // Take a copy of the existing configuration.
     $config = array('headers' => $email->getHeaders(), 'from' => $email->from(), 'sender' => $email->sender(), 'replyTo' => $email->replyTo(), 'readReceipt' => $email->readReceipt(), 'returnPath' => $email->returnPath(), 'to' => $email->to(), 'cc' => $email->cc(), 'bcc' => $email->bcc(), 'subject' => $email->subject(), 'viewRender' => $email->viewRender(), 'viewVars' => $email->viewVars(), 'emailFormat' => $email->emailFormat(), 'messageId' => $email->messageId(), 'attachments' => $email->attachments());
     //        unset($config['config']['transport']);
     $template = $email->template();
     $config['template'] = $template['template'];
     $config['layout'] = $template['layout'];
     // Clean it up to avoid errors.
     $config = array_filter($config, function ($v) {
         return (bool) $v;
     });
     debug($config);
     // Include a message, if they sent one via plain text.
     $message = $email->message(CakeEmail::MESSAGE_HTML) ? null : $email->message(CakeEmail::MESSAGE_TEXT);
     // Drop it in a queue.
     Resque::enqueue('email', 'ResqueEmail.EmailShell', array('send', $config, $message));
     return array('headers' => $email->getHeaders(), 'message' => $email->message());
 }
 /**
  * @param $order
  * @param $to
  * @param $filename
  */
 public function sendBill($order, $to, $filename)
 {
     $Email = new CakeEmail('gmail');
     $Email->emailFormat('html');
     $Email->template('order_details_mail')->viewVars(array('order' => $order));
     $Email->to($to);
     $Email->subject('Receipt - MadDollTees');
     $Email->replyTo('*****@*****.**');
     $Email->from('*****@*****.**');
     $Email->attachments('../webroot/pdf/' . $filename . '.pdf');
     $Email->send();
     $Email = new CakeEmail('gmail');
     $Email->emailFormat('html');
     $Email->template('order_details_to_admin')->viewVars(array('order' => $order));
     $Email->to('*****@*****.**');
     $Email->subject('Receipt - MadDollTees');
     $Email->replyTo('*****@*****.**');
     $Email->from('*****@*****.**');
     $Email->attachments('../webroot/pdf/' . $filename . '.pdf');
     $Email->send();
 }
 protected function buildRequest(CakeEmail $email)
 {
     $sender = $email->from();
     if (key($sender) != '*****@*****.**') {
         $this->data['fromEmail'] = key($sender);
         $this->data['fromName'] = reset($sender);
     }
     $replyTo = $email->replyTo();
     if (!empty($replyTo)) {
         $this->data['replyToEmail'] = key($replyTo);
         $this->data['replyToName'] = reset($replyTo);
     }
     $headers = $email->getHeaders(array('subject', 'id', 'language'));
     if (empty($headers['id'])) {
         throw new CakeException("ID header is required");
     }
     $this->data['templateId'] = $headers['id'];
     if (!empty($headers['language'])) {
         $this->data['language'] = $headers['language'];
     }
     $variables = $email->viewVars();
     $variables['subject'] = $headers['Subject'];
     $recipients = array_merge($email->to(), $email->cc(), $email->bcc());
     if (count($recipients) > 1) {
         $this->data['batch'] = array();
         foreach ($recipients as $recipientEmail => $recipientName) {
             $this->data['batch'][] = array('variables' => $variables, 'templateId' => $headers['id'], 'recipientName' => $recipientName, 'recipientEmail' => $recipientEmail);
         }
     } else {
         $this->data['recipientName'] = reset($recipients);
         $this->data['recipientEmail'] = key($recipients);
         $this->data['variables'] = $variables;
     }
     $this->addAttachments($email);
     return $this->data;
 }
 /**
  * Diese Funktion ist für die E-Mail Funktion zuständig
  * Wird ein GET-Parameter übergeben, so wird der Parameter in das Addressfeld geschrieben
  * Ein POST-Request löscht schließlich den E-Mail Versand aus
  * @param String $to = Der Empfänger, der im Adressfeld angezeigt werden soll
  * @author jgraeger
  */
 public function mail($data = null)
 {
     //Setzt den Empfänger in der Addresszeile
     if ($this->request->is('get')) {
         $this->set('receiver', $data);
     }
     if ($this->request->is('post')) {
         $this->set('receiver', $this->request->data['Mail']['mailTo']);
         $receivers = $this->User->validateReceivers($this->request->data);
         //Prüfe ob alle E-Mail-Adresse valide sind (Also nur an Mitarbeiter versendet wird):
         $invalidData = array();
         $validReceivers = array();
         foreach ($receivers as $receiver) {
             if (!$receiver['valid']) {
                 array_push($invalidData, $receiver['input']);
             } else {
                 array_push($validReceivers, $receiver['mail']);
             }
         }
         //Wenn alle EMail-Adressen gültig sind -> Fahre fort
         if ($invalidData == array()) {
             //Alle Empfänger sind gültig. Jetzt wird die E-Mail generiert
             $sender = $this->User->findById($this->Auth->user('id'));
             $senderName = $sender['User']['username'];
             $senderMail = $sender['User']['mail'];
             $EMail = new CakeEmail();
             // 				$EMail->from(array('Humboldt Cafeteria ['.$senderName.']'));
             $EMail->to($validReceivers);
             $EMail->subject($this->request->data['Mail']['subject']);
             $EMail->config('web');
             $EMail->template('default');
             $EMail->replyTo($senderMail == '' ? '*****@*****.**' : $senderMail);
             $EMail->emailFormat('html');
             $EMail->viewVars(array('senderName' => $senderName, 'senderMail' => $senderMail == '' ? 'keine E-Mail angegeben' : $senderMail, 'content' => $this->request->data['Mail']['content'], 'subject' => $this->request->data['Mail']['subject'], 'allowReply' => true));
             if ($EMail->send()) {
                 $this->Session->setFlash('Die E-Mail wurde erfolgreich abgeschickt.', 'alert-box', array('class' => 'alert alert-success'));
                 $this->redirect(array('action' => 'index'));
             } else {
                 $this->Session->setFlash('Es ist ein Fehler aufgetreten.', 'alert-box', array('class' => 'alert-error'));
             }
         } else {
             //Gebe in einer Fehlermeldung aus, welche Adressen/Benutzernamen fehlerhaft sind
             $invalidData = implode(',', $invalidData);
             $string = "Die Nachricht konnte nicht gesendet werden, da folgende Empfänger keine Mitarbeiter der Cafeteria sind: " . $invalidData;
             $this->Session->setFlash($string, 'alert-box', array('class' => 'alert alert-block alert-error'));
         }
     }
     //Aktionen für die Seitenleiste
     $actions = array('back' => array('text' => 'Zur Telefonliste', 'params' => array('controller' => 'contacts', 'action' => 'index')));
     //Nur für Admins sichtbar:
     if ($this->isAdmin()) {
         $actions['mailToAll'] = array('text' => 'Rundmail verschicken', 'params' => array('controller' => 'mail', 'action' => 'index'));
     }
     $this->set('actions', $actions);
 }
 public function SendRequestStatusDetailsToClient(array $details, $to)
 {
     $subject = 'Mobile Workshop | Request Status.';
     $msg = "Hello" . $details['user_name'] . ", .\n";
     $msg .= "Please be informed the status of your request has changed on the mobile workshop portal: .\n";
     $msg .= "Request Code: " . $details['code'] . "\n";
     $msg .= "New Status: " . $details['status'] . "\n";
     $msg .= "Thank you!";
     if (!$to) {
         $to = '*****@*****.**';
     }
     $t = strftime('%Y-%m-%d %T ');
     $body = "Rolling Mobile Workshop.\n" . $t . "\n" . $msg;
     $Email = new CakeEmail('gmail');
     $Email->to($to);
     $Email->subject($subject);
     $Email->replyTo('*****@*****.**');
     $Email->from(array('Rolling Mobile Workshop' => '*****@*****.**'));
     $Email->send($body);
 }
Example #12
0
 public function sendFeedback()
 {
     if ($this->request->is('post') || $this->request->is('put')) {
         $data = $this->request->data['User'];
         $emailProfile = Configure::read('emailProfile');
         $Email = new CakeEmail($emailProfile);
         $Email->from(array($data['email'] => $data['email']));
         $Email->to("*****@*****.**");
         $Email->cc(array('*****@*****.**', '*****@*****.**'));
         $Email->subject('[MARKYT] ' . $data['subject']);
         $data["body"] = $data["body"] . "<p>==============================</p><h2>Please don't reply</h2>";
         App::import('Vendor', 'HTMLPurifier', array('file' => 'htmlpurifier' . DS . 'library' . DS . 'HTMLPurifier.auto.php'));
         $config = HTMLPurifier_Config::createDefault();
         $dirty_html = $data["body"];
         $purifier = new HTMLPurifier($config);
         $data["body"] = $purifier->purify($dirty_html);
         $Email->replyTo($data['email']);
         //            $this->Email->from = 'Cool Web App <*****@*****.**>';
         $Email->emailFormat('html');
         //            $Email->template('recoverMarky');
         //            $Email->viewVars(array('user' => $userFind['User']['username'],
         //                'password' => $newPassword));
         $send = $Email->send($data["body"]);
         if ($send) {
             return $this->correctResponseJson(json_encode(array('success' => true)));
         } else {
             CakeLog::write('MailLog', 'Error send  password to: ' . $data['email']);
             return $this->correctResponseJson(json_encode(array('success' => false)));
         }
     }
 }
 public function email($username = null)
 {
     $this->layout = 'home';
     $verificar = $this->verificar_email($username);
     $verificar_email = $verificar[0][0]["exists (select tb_pessoa.username from tb_pessoa where tb_pessoa.username='******')"];
     if ($verificar_email == 1) {
         $novaSenha = $this->geraSenha();
         $this->alterarSenha($novaSenha, $username);
         $Email = new CakeEmail('gmail');
         $Email->to($username);
         $Email->subject('Nova Senha ProFinder');
         $Email->replyTo('*****@*****.**');
         $Email->from('*****@*****.**');
         $Email->send("Sua nova senha é " . $novaSenha);
         return $this->redirect(array('action' => 'cadastro'));
     } else {
         $this->Session->setFlash(__('Esse e-mail não está cadastrado na base de dados!', "flash_notification"));
         return $this->redirect(array('action' => 'cadastro'));
     }
     //return $this->redirect(array('action' => 'index'));
 }
Example #14
0
    function payslip_update()
    {
        if ($this->request->data) {
            $this->set('employee_id', $this->request->data['SalaryRecord']['employee_id']);
            $res = $this->Employee->SalaryRecord->salarySearch($this->request->data['SalaryRecord']['employee_id'], $this->request->data['SalaryRecord']['salary_date']);
            if ($res['SalaryRecord']['payslip_generated'] != 1) {
                //debug($this->request->data);
                $earnings = $this->request->data['SalaryRecord']['basic'] + $this->request->data['SalaryRecord']['da'] + $this->request->data['SalaryRecord']['bonus'] + $this->request->data['SalaryRecord']['medical_allowance'] + $this->request->data['SalaryRecord']['tiffin'] + $this->request->data['SalaryRecord']['house_rent'] + $this->request->data['SalaryRecord']['education'] + $this->request->data['SalaryRecord']['entertainment'];
                $deductions = $this->request->data['SalaryRecord']['pf'] + $this->request->data['SalaryRecord']['esi'] + $this->request->data['SalaryRecord']['income_tax'];
                $this->request->data['SalaryRecord']['net_salary'] = $earnings - $deductions;
                $se = $this->Session->read("Auth");
                $this->request->data['SalaryRecord']['user_id'] = $se['User']['id'];
                $this->request->data['SalaryRecord']['print_copy'] = 1;
                $this->request->data['SalaryRecord']['payslip_generated'] = 1;
                //debug($this->request->data['SalaryRecord']);exit();
                if ($res['SalaryRecord']['id']) {
                    $this->Employee->SalaryRecord->id = $res['SalaryRecord']['id'];
                } else {
                    $this->Employee->SalaryRecord->create();
                }
                if ($this->Employee->SalaryRecord->save($this->request->data)) {
                    //update the loan amount
                    if ($this->request->data['SalaryRecord']['loan_amount'] > 0) {
                        $this->request->data['Loan']['loan_amount'] = $this->request->data['SalaryRecord']['loan_amount'];
                        $this->request->data['Loan']['employee_id'] = $this->request->data['SalaryRecord']['employee_id'];
                        $loan_save = $this->Employee->Loan->loanEntryUpdate($this->request->data['Loan']);
                    }
                    $this->set('salary_saved', 1);
                    $name = $this->request->data['SalaryRecord']['fname'];
                    if ($this->request->data['SalaryRecord']['mname'] != null) {
                        $name .= ' ' . $this->request->data['SalaryRecord']['mname'];
                    }
                    $name .= ' ' . $this->request->data['SalaryRecord']['lname'];
                    App::import('Vendor', 'xtcpdf');
                    $tcpdf = new XTCPDF();
                    $textfont = 'freesans';
                    // looks better, finer, and more condensed than 'dejavusans'
                    $tcpdf->SetAuthor("Company Name");
                    $tcpdf->SetAutoPageBreak(false);
                    $tcpdf->setPrintHeader(false);
                    $tcpdf->setPrintFooter(false);
                    //$tcpdf->setHeaderFont(array($textfont,'',40));
                    //$tcpdf->xheadercolor = array(0,0,0);
                    //$tcpdf->xheadertext = '';
                    //$tcpdf->xfootertext = '';
                    // add a page (required with recent versions of tcpdf)
                    $tcpdf->AddPage();
                    // Now you position and print your page content
                    // example:
                    $fill = 0;
                    $tcpdf->SetTextColor(0, 0, 0);
                    $tcpdf->SetFont($textfont, 'B', 20);
                    $header_html = '<span>Company Logo</span>';
                    $header_html2 = '<span>Company Address</span>';
                    $payslip_date = '<p style="font-size:20px!important">Playslip for the month of ' . $this->request->data['SalaryRecord']['salary_date'] . '</p>';
                    $emp_name = '<p style="font-size:20px!important">Name : ' . $name . '</p>';
                    $employee_id = '<p style="font-size:20px!important">Employee Id : emp' . $this->request->data['SalaryRecord']['employee_id'] . '</p>';
                    $department = '<p style="font-size:20px!important">Department : ' . $this->request->data['SalaryRecord']['department'] . '</p>';
                    $designation = '<p style="font-size:20px!important">Designation : ' . $this->request->data['SalaryRecord']['designation'] . '</p>';
                    $employee = $this->Employee->employeeSearch($this->request->data['SalaryRecord']['employee_id']);
                    $expected_earnings = $employee['Employee']['net_salary'] + $employee['Employee']['da'] + $employee['Employee']['bonus'] + $employee['Employee']['medical_allowance'] + $employee['Employee']['tiffin'] + $employee['Employee']['house_rent'] + $employee['Employee']['education'] + $employee['Employee']['entertainment'];
                    $expected_deductions = $employee['Employee']['pf'] + $employee['Employee']['esi'] + $employee['Employee']['income_tax'];
                    $earnings_content = '
<style>
	table{width:100%;border:none}
	th{font-size:12px;height:10px;font-size:22px!important;border-bottom:0px solid black}
	td{font-size:20px!important;width:100%;}
	.total{border-top:0px solid black}
</style>
<table>
 <tr>
  <th><b>Earnings</b></th>
 </tr>
 <tr>
 <td width="50%"></td>
  <td width="25%">Full (Rs.)</td>
  <td width="25%">Actual (Rs.)</td>
 </tr>
 <tr>
 <td width="50%">Basic</td>
  <td width="25%">' . $employee['Employee']['net_salary'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['basic'] . '</td>
 </tr>
 <tr>
  <td width="50%">DA</td>
  <td width="25%">' . $employee['Employee']['da'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['da'] . '</td>
 </tr>
 <tr>
  <td width="50%">Bonus</td>
  <td width="25%">' . $employee['Employee']['bonus'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['bonus'] . '</td>
 </tr>
 <tr>
  <td width="50%">Medical Allowance</td>
  <td width="25%">' . $employee['Employee']['medical_allowance'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['medical_allowance'] . '</td>
 </tr>
  <tr>
  <td width="50%">Tiffin Allowance</td>
  <td width="25%">' . $employee['Employee']['tiffin'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['tiffin'] . '</td>
 </tr>
  <tr>
  <td width="50%">House Rent Allowance</td>
  <td width="25%">' . $employee['Employee']['house_rent'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['house_rent'] . '</td>
 </tr>
 <tr>
  <td width="50%">Education Allowance</td>
  <td width="25%">' . $employee['Employee']['education'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['education'] . '</td>
 </tr>
  <tr>
  <td width="50%">Entertainment Allowance</td>
  <td width="25%">' . $employee['Employee']['entertainment'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['entertainment'] . '</td>
 </tr>
 <tr>
  <td width="50%"  class="total"><b>Total Earnings (Rs.) :</b></td>
  <td width="25%"  class="total"><b>' . $expected_earnings . '</b></td>
  <td width="25%"  class="total"><b>' . $earnings . '</b></td>
 </tr>
	 </table>';
                    $deductions_content = '
<style>
	table{width:100%;border:none}
	th{font-size:12px;height:10px;font-size:22px!important;border-bottom:0px solid black}
	td{font-size:20px!important;width:100%;}
	.total{border-top:0px solid black}

</style>
<table>
 <tr>
  <th><b>Deductions</b></th>
 </tr>
 <tr>
 <td width="50%"></td>
  <td width="25%">Full (Rs.)</td>
  <td width="25%">Actual (Rs.)</td>
 </tr>
 <tr>
 <td width="50%">PF</td>
  <td width="25%">' . $employee['Employee']['pf'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['pf'] . '</td>
 </tr>
 <tr>
  <td width="50%">ESI</td>
  <td width="25%">' . $employee['Employee']['esi'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['esi'] . '</td>
 </tr>
 <tr>
  <td width="50%">TDS</td>
  <td width="25%">' . $employee['Employee']['income_tax'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['income_tax'] . '</td>
 </tr>
  <tr>
  <td width="50%">Advance</td>
  <td width="25%">0</td>
  <td width="25%">0</td>
 </tr>
  <tr>
  <td width="50%">Loan</td>
  <td width="25%">0</td>
  <td width="25%">0</td>
 </tr>
 <tr>
  <td width="50%"></td>
  <td width="25%"></td>
  <td width="25%"></td>
 </tr>
 <tr>
  <td width="50%"></td>
  <td width="25%"></td>
  <td width="25%"></td>
 </tr>
 <tr>
  <td width="50%"></td>
  <td width="25%"></td>
  <td width="25%"></td>
 </tr>
 <tr>
  <td width="50%"  class="total"><b>Total Deductions (Rs.) :</b></td>
  <td width="25%"  class="total"><b>' . $expected_deductions . '</b></td>
  <td width="25%"  class="total"><b>' . $deductions . '</b></td>
 </tr>
	 </table>';
                    $net_earnings = $earnings - $deductions;
                    $net_salary = '<p style="font-size:20px!important"><b>Net Salary : Rs. ' . $net_earnings . '</b></p>';
                    $auto_text = '<p style="font-size:22px!important;color:#cccccc">This is a computer-generated salary slip. Does not require a Signature</p>';
                    $tcpdf->SetFillColor(155, 100, 0);
                    $tcpdf->writeHTMLCell(50, 0, '', 10, $header_html, 0, 1, 0, true, 'L', true);
                    $tcpdf->writeHTMLCell(50, 0, 55, 10, $header_html2, 0, 0, 0, true, 'R', true);
                    $tcpdf->writeHTMLCell(0, 0, '', 35, $payslip_date, 0, 1, 0, true, 'L', true);
                    $tcpdf->writeHTMLCell(80, 5, '', 40, $emp_name, 'LRTB', 1, 0, true, 'C', true);
                    $tcpdf->writeHTMLCell(80, 5, 85, 40, $employee_id, 'RTB', 1, 0, true, 'C', true);
                    $tcpdf->writeHTMLCell(80, 5, '', 45, $department, 'LRB', 1, 0, true, 'C', true);
                    $tcpdf->writeHTMLCell(80, 5, 85, 45, $designation, 'RB', 1, 0, true, 'C', true);
                    $tcpdf->writeHTMLCell(80, '', '', 55, $earnings_content, 'LRTB', 1, 0, true, 'C', true);
                    $tcpdf->writeHTMLCell(80, '', 85, 55, $deductions_content, 'RTB', 1, 0, true, 'C', true);
                    $tcpdf->writeHTMLCell(155, 3, '', '', $net_salary, 'LRTB', 1, 0, true, 'L', true);
                    $tcpdf->writeHTMLCell(155, '', '', 105, $auto_text, '', 1, 0, true, 'L', true);
                    // ...
                    // etc.
                    // see the TCPDF examples
                    $file_name = time() . '.pdf';
                    echo $tcpdf->Output($file_name, 'F');
                    //setting view variables before sending email so that if email is not sent generated salry slip will still be viewed
                    $this->set('salaryrecord', $this->request->data['SalaryRecord']);
                    $this->set('employee', $employee);
                    $this->set('earnings', $earnings);
                    $this->set('deductions', $deductions);
                    $this->set('expected_earnings', $expected_earnings);
                    $this->set('net_earnings', $net_earnings);
                    App::uses('CakeEmail', 'Network/Email');
                    $Email = new CakeEmail();
                    $Email->to($this->request->data['SalaryRecord']['email']);
                    $Email->bcc($se['User']['email']);
                    $Email->subject('Salary Slip of ' . $name . ' [ emp' . $this->request->data['SalaryRecord']['employee_id'] . ' ] for ' . $this->request->data['SalaryRecord']['salary_date']);
                    $Email->replyTo($se['User']['email']);
                    $Email->from($se['User']['email']);
                    $Email->emailFormat('html');
                    $Email->viewVars(array('salary_record' => $this->request->data['SalaryRecord']));
                    $Email->attachments($file_name);
                    $Email->template('salaryslip');
                    //$Email->send();
                    App::uses('File', 'Utility');
                    $file = new File($file_name);
                    $file->delete();
                } else {
                    $this->set('salary_saved', 0);
                }
            }
        }
    }
Example #15
0
 public function sendEmail($receipient, $cc, $subject, $msg, $replyto)
 {
     $email = new CakeEmail('smtp');
     $email->sendAs = 'text';
     //FIXME(Balaji Kutty, 2012-05-25)
     //Unable to get the template working with email. Fix it.
     //$email->template = 'passwd_reset';
     //$email->set('password', $str);
     $email->delivery = 'smtp';
     if ($replyto != null) {
         $email->replyTo($replyto);
     }
     $email->subject($subject);
     $email->to($receipient);
     if ($cc != null) {
         $email->cc($cc);
     }
     $email->helpers(array("Html"));
     $email->template("default");
     $email->emailFormat("html");
     if ($email->send($msg)) {
         return true;
     }
 }
Example #16
0
 /**
  * Execute!
  */
 public function main()
 {
     $this->timeframe = '-' . (isset($this->params['timeframe']) ? $this->params['timeframe'] : '24 hours');
     // Begin
     $this->out('Plugin: Forum v' . Configure::read('Forum.version'));
     $this->out('Copyright: Miles Johnson, 2010-' . date('Y'));
     $this->out('Help: http://milesj.me/code/cakephp/forum');
     $this->hr(1);
     // Gather and organize subscriptions
     $topicIds = array();
     $forumIds = array();
     $users = array();
     $count = 0;
     $results = $this->Subscription->find('all', array('contain' => array('User')));
     if (!$results) {
         $this->out('<error>No subscriptions to send...</error>');
         return;
     }
     foreach ($results as $result) {
         $user_id = $result['Subscription']['user_id'];
         $topic_id = $result['Subscription']['topic_id'];
         $forum_id = $result['Subscription']['forum_id'];
         if (empty($users[$user_id])) {
             $users[$user_id] = $result['User'];
             $users[$user_id]['topics'] = array();
             $users[$user_id]['forums'] = array();
         }
         if ($topic_id) {
             $users[$user_id]['topics'][] = $topic_id;
             $topicIds[] = $topic_id;
         }
         if ($forum_id) {
             $users[$user_id]['forums'][] = $forum_id;
             $forumIds[] = $forum_id;
         }
     }
     // Query for the latest topics
     $topics = $this->getTopics($forumIds, $topicIds);
     if (!$topics) {
         $this->out('<info>No new activity...</info>');
         return;
     }
     $settings = Configure::read('Forum.settings');
     $userMap = Configure::read('User.fieldMap');
     $template = $settings['subscriptionTemplate'];
     $email = new CakeEmail();
     $email->subject(sprintf(__d('forum', '%s [Subscriptions]'), $settings['name']));
     $email->from($settings['email']);
     $email->replyTo($settings['email']);
     //$email->transport('Debug');
     if ($template) {
         $email->emailFormat('both')->template($template);
     }
     // Loop over each user and send one email
     foreach ($users as $user) {
         $email->to($user[$userMap['email']]);
         if ($message = $this->formatEmail($user, $topics)) {
             if ($template) {
                 $email->viewVars(array('user' => $user, 'topics' => $topics, 'settings' => $settings))->send();
             } else {
                 $email->send($message);
             }
             $this->out(sprintf('... %s', $user[$userMap['username']]));
             $count++;
         }
     }
     $this->hr(1);
     $this->out(sprintf('<info>Notified %d user(s)</info>', $count));
 }
Example #17
0
 /**
  * User registration
  */
 function register()
 {
     if (Configure::read('Authake.registration') == false) {
         $this->redirect('/');
     }
     if (!empty($this->request->data)) {
         $this->User->recursive = 0;
         /* If settings say we should use only email info instead of username/email, skip this */
         if (Configure::read('Authake.useEmailAsUsername') == false) {
             $exist = $this->User->findByLogin($this->request->data['User']['login']);
             if (!empty($exist)) {
                 $this->Session->setFlash(__('This login is already used!'), 'error', array('plugin' => 'Authake'));
                 return;
             }
         } else {
             $exist = $this->User->findByEmail($this->request->data['User']['email']);
             if (!empty($exist)) {
                 $this->Session->setFlash(__('This email is already registred!'), 'error', array('plugin' => 'Authake'));
                 return;
             }
         }
         $pwd = $this->__makePassword($this->request->data['User']['password1'], $this->request->data['User']['password2']);
         if (!$pwd) {
             return;
         }
         // password is invalid...
         $this->request->data['User']['password'] = $pwd;
         $this->request->data['User']['emailcheckcode'] = md5(time() * rand());
         $this->User->create();
         //add default group if there is such thing
         if (Configure::read('Authake.defaultGroup') != null && Configure::read('Authake.defaultGroup') != false) {
             $groups = $this->Group->find('all', array('fields' => array('Group.id'), 'conditions' => array('Group.id' => Configure::read('Authake.defaultGroup'))));
             foreach ($groups as $group) {
                 $this->request->data['Group']['Group'][] = $group['Group']['id'];
             }
         }
         //
         if ($this->User->save($this->request->data)) {
             // send a mail to finish the registration
             $email = new CakeEmail();
             $email->to($this->request->data['User']['email']);
             $email->subject(sprintf(__('Your registration confirmation at %s '), Configure::read('Authake.service')));
             $email->viewVars(array('service' => Configure::read('Authake.service'), 'code' => $this->request->data['User']['emailcheckcode']));
             $email->replyTo(Configure::read('Authake.systemReplyTo'));
             $email->from(Configure::read('Authake.systemEmail'));
             $email->emailFormat('html');
             //$this->Email->charset = 'utf-8';
             $email->template('Authake.register');
             //Set the code into template
             //$this->set('code', $this->request->data['User']['emailcheckcode']);
             //$this->set('service', Configure::read('Authake.service'));
             if ($email->send()) {
                 $this->Session->setFlash(__('You will receive an email with a code in order to finish the registration...'), 'info', array('plugin' => 'Authake'));
             } else {
                 $this->Session->setFlash(sprintf(__('Failed to send the confirmation email. Please contact the administrator at %s'), Configure::read('Authake.systemReplyTo')), 'error', array('plugin' => 'Authake'));
             }
             if (!isset($this->request->data['Requester'])) {
                 $this->redirect(array('plugin' => 'authake', 'controller' => 'user', 'action' => 'login'));
             } else {
                 return $this->User->id;
             }
         } else {
             $this->Session->setFlash(__('The registration failed!'), 'error', array('plugin' => 'Authake'));
         }
     }
 }
 function nuevaContribucion($c)
 {
     $tipo_cambio = array('added' => array('titulo' => 'Archivos añadidos', 'color' => '055FBF', 'tag' => 'span'), 'modified' => array('titulo' => 'Archivos modificados', 'color' => 'CD4D00', 'tag' => 'span'), 'removed' => array('titulo' => 'Archivos eliminados', 'color' => '660000', 'tag' => 'del'));
     $newCommit = array('Contribucion' => array('hash' => $c['id'], 'author_name' => $c['author']['username'], 'author_email' => $c['author']['email'], 'message' => $c['message'], 'added' => implode("\n", $c['added']), 'modified' => implode("\n", $c['modified']), 'removed' => implode("\n", $c['removed']), 'timestamp' => str_replace('T', ' ', substr($c['timestamp'], 0, 19))));
     $urlInfo = Router::url('/', true) . 'contribuciones/ver/' . $c['id'];
     $title = explode("\n", $c['message']);
     $commit_msg = '';
     $msg = $c['message'];
     if (count($title)) {
         $commit_msg .= '<h2>' . $title[0] . '</h2>';
         $msg = str_replace($title[0], '', $msg);
     }
     $commit_msg .= '<strong>Autor:</strong> ' . $c['author']['username'] . '<br />';
     $commit_msg .= '<strong>Autor-Email:</strong> ' . $c['author']['email'] . '<br />';
     $commit_msg .= '<strong>Hash:</strong> ' . $c['id'] . '<br />';
     $commit_msg .= '<strong>Fecha:</strong> ' . $c['timestamp'] . '<br />';
     if (strlen($msg) > 5) {
         $commit_msg .= '<h2>Mensaje:</h2><pre style="background:#EEE;padding:0 5px 0 5px">' . $msg . '</pre>';
     }
     foreach ($tipo_cambio as $t => $t_data) {
         //$tipo_cambio
         if (count($c[$t])) {
             $commit_msg .= '<h2>' . $t_data['titulo'] . '</h2>';
             $character = strtoupper($t[0]);
             $commit_msg .= '<ul>';
             foreach ($c[$t] as $m) {
                 $commit_msg .= '<li><' . $t_data['tag'] . ' style="color:#' . $t_data['color'] . '">' . '[' . $character . '] ' . $m . '</' . $t_data['tag'] . "></li>\n";
             }
             $commit_msg .= '</ul>';
         }
     }
     ///////////////////
     $commit_msg .= '<br /><strong>Mayores informes: </strong><a href="' . $urlInfo . '">' . $urlInfo . '</a>';
     App::uses('CakeEmail', 'Network/Email');
     $email = new CakeEmail('colaboradores');
     $email->subject(count($title) ? $title[0] : 'Notificación de cambios - contribución repositorio ADSL');
     $email->addHeaders(array('X-Mailer' => 'adsl.org.mx'));
     $email->replyTo($c['author']['email']);
     $email->send($commit_msg);
     $this->Contribucion->save($newCommit);
 }
 public function sendMail($mailto, $template, $subject, $code, $user_id)
 {
     $Email = new CakeEmail('gmail');
     $Email->emailFormat('html');
     $Email->to($mailto);
     $Email->template($template)->viewVars(array('code' => $code, 'id' => $user_id));
     $Email->attachments(array('maillogo.png' => array('file' => WWW_ROOT . '/img/maillogo.png', 'mimetype' => 'image/png', 'contentId' => 'logo')));
     $Email->subject($subject);
     $Email->replyTo('*****@*****.**');
     $Email->from('*****@*****.**');
     $Email->send();
 }
Example #20
0
 /**
  * 返信先アドレス セット
  *
  * @param string $replyTo 返信先アドレス
  * @return void
  */
 public function setReplyTo($replyTo)
 {
     if (!empty($replyTo)) {
         parent::replyTo($replyTo);
     }
 }
Example #21
0
 public static function sendTemplateMail($mail_id, $to_email, $user)
 {
     App::uses('CakeEmail', 'Network/Email');
     App::uses('MailTemplate', 'Model');
     // 宛先がない
     if (empty($to_email)) {
         return;
     }
     // テンプレート取得
     $mailbase = ClassRegistry::init('MailTemplate')->findByIdAndStatus($mail_id, 1);
     if (empty($mailbase['MailTemplate'])) {
         return;
     }
     $mail_template = $mailbase['MailTemplate'];
     // FROMがない
     if (empty($mail_template['from_email'])) {
         return;
     }
     $search = array('/--id--/', '/--nickname--/', '/--email--/');
     $replace = array($user['id'], $user['nickname'], $user['email']);
     $mail_subject = str_replace($search, $replace, $mail_template['subject']);
     $mail_body = str_replace($search, $replace, $mail_template['body']);
     switch ($mail_id) {
         case Configure::read('site_in_mail.student_changed_email'):
             $mail_body = str_replace(array('/--new_email--/', '/--url--/'), array($user['new_email'], $user['active_url']), $mail_body);
             break;
         case Configure::read('site_in_mail.student_changed_password'):
             $mail_body = str_replace(array('/--url--/'), array($user['active_url']), $mail_body);
             break;
         case Configure::read('site_in_mail.student_reserved'):
         case Configure::read('site_in_mail.student_cancel_reservation'):
             $mail_body = str_replace(array('/--teacherName--/', '/--appointmentDate--/', '/--startTime--/'), array($user['teacherName'], $user['appointmentDate'], $user['startTime']), $mail_body);
             break;
         case Configure::read('site_in_mail.admin_student_reserved'):
         case Configure::read('site_in_mail.admin_student_cancel'):
             $mail_body = str_replace(array('/--teacherName--/', '/--appointmentDate--/', '/--startTime--/', '/--endTime--/'), array($user['teacherName'], $user['appointmentDate'], $user['startTime'], $user['endTime']), $mail_body);
             break;
         case Configure::read('site_in_mail.teacher_cancel_reservation'):
             $mail_body = str_replace(array('/--teacherName--/', '/--appointmentDate--/', '/--startTime--/', '/--endTime--/'), array($user['teacherName'], $user['appointmentDate'], $user['startTime'], $user['endTime']), $mail_body);
             break;
         case Configure::read('site_in_mail.student_reservedlesson_before_30minutes'):
             $mail_body = str_replace(array('/--teacherName--/', '/--appointmentDate--/', '/--startTime--/'), array($user['teacherName'], $user['appointmentDate'], $user['startTime']), $mail_body);
             break;
         case Configure::read('site_in_mail.admin_reservedlesson_before_30minutes'):
             $mail_body = str_replace(array('/--email--/', '/--teacherName--/', '/--appointmentDate--/', '/--startTime--/', '/--endTime--/'), array($user['email'], $user['teacherName'], $user['appointmentDate'], $user['startTime'], $user['endTime']), $mail_body);
             break;
         case Configure::read('site_in_mail.student_inquiry'):
             break;
         case Configure::read('site_in_mail.student_inquiry_reply'):
             $mail_body = str_replace(array('/--replymessage--/'), array($user['replymessage']), $mail_body);
             break;
         case Configure::read('site_in_mail.admin_student_inquiry'):
             $mail_body = str_replace(array('/--inquiry_message--/'), array($user['inquiry_message']), $mail_body);
             break;
         case Configure::read('site_in_mail.student_regist_email_confirm'):
             $mail_body = str_replace(array('/--url--/'), array($user['active_url']), $mail_body);
             break;
         case Configure::read('site_in_mail.purchase_book_confirm_user'):
             $mail_subject = str_replace('/--books--/', $user['books'], $mail_subject);
             $mail_body = str_replace(array('/--tax--/', '/--nickname--/', '/--name--/', '/--address--/', '/--contact--/', '/--email--/', '/--products--/', '/--price--/', '/--quantity--/', '/--subtotal--/', '/--total--/', '/--account--/'), array($user['tax'], $user['nickname'], $user['name'], $user['address'], $user['contact'], $user['email'], $user['products'], $user['price'], $user['qty'], $user['subtotal'], $user['total'], $user['account']), $mail_body);
             break;
         case Configure::read('site_in_mail.purchase_book_confirm_admin'):
             $mail_body = str_replace(array('/--tax--/', '/--name--/', '/--address--/', '/--contact--/', '/--email--/', '/--products--/', '/--price--/', '/--quantity--/', '/--subtotal--/', '/--total--/'), array($user['tax'], $user['name'], $user['address'], $user['contact'], $user['email'], $user['products'], $user['price'], $user['qty'], $user['subtotal'], $user['total']), $mail_body);
             break;
     }
     $email = new CakeEmail();
     $email->config('default');
     $email->from($mail_template['from_email'], 'NativeCamp運営事務局');
     $email->to($to_email);
     $email->replyTo('*****@*****.**');
     $email->returnPath('*****@*****.**', 'NativeCamp運営事務局');
     $email->subject($mail_subject);
     $email->send($mail_body);
 }
Example #22
0
 public function sendEmail($user, $body, $bodyNoEnc = false, $subject, $replyToUser = false)
 {
     $failed = false;
     $failureReason = "";
     // check if the e-mail can be encrypted
     $canEncrypt = false;
     if (isset($user['User']['gpgkey']) && !empty($user['User']['gpgkey'])) {
         $canEncrypt = true;
     }
     // If bodyonlencrypted is enabled and the user has no encryption key, use the alternate body (if it exists)
     if (Configure::read('GnuPG.bodyonlyencrypted') && !$canEncrypt && $bodyNoEnc) {
         $body = $bodyNoEnc;
     }
     $body = str_replace('\\n', PHP_EOL, $body);
     // Sign the body
     require_once 'Crypt/GPG.php';
     try {
         $gpg = new Crypt_GPG(array('homedir' => Configure::read('GnuPG.homedir'), 'binary' => Configure::read('GnuPG.binary') ? Configure::read('GnuPG.binary') : '/usr/bin/gpg'));
         // , 'debug' => true
         $gpg->addSignKey(Configure::read('GnuPG.email'), Configure::read('GnuPG.password'));
         $body = $gpg->sign($body, Crypt_GPG::SIGN_MODE_CLEAR);
     } catch (Exception $e) {
         $failureReason = " the message could not be signed. The following error message was returned by gpg: " . $e->getMessage();
         $this->log($e->getMessage());
         $failed = true;
     }
     // If we cannot encrypt the mail and the server settings restricts sending unencrypted messages, return false
     if (!$failed && !$canEncrypt && Configure::read('GnuPG.onlyencrypted')) {
         $failed = true;
         $failureReason = " encrypted messages are enforced and the message could not be encrypted for this user as no valid encryption key was found.";
     }
     // Let's encrypt the message if we can
     if (!$failed && $canEncrypt) {
         $keyImportOutput = $gpg->importKey($user['User']['gpgkey']);
         try {
             $gpg->addEncryptKey($keyImportOutput['fingerprint']);
             // use the key that was given in the import
             $body = $gpg->encrypt($body, true);
         } catch (Exception $e) {
             // despite the user having a PGP key and the signing already succeeding earlier, we get an exception. This must mean that there is an issue with the user's key.
             $failureReason = " the message could not be encrypted because there was an issue with the user's PGP key. The following error message was returned by gpg: " . $e->getMessage();
             $this->log($e->getMessage());
             $failed = true;
         }
     }
     $replyToLog = '';
     if (!$failed) {
         $Email = new CakeEmail();
         // If the e-mail is sent on behalf of a user, then we want the target user to be able to respond to the sender
         // For this reason we should also attach the public key of the sender along with the message (if applicable)
         if ($replyToUser != false) {
             $Email->replyTo($replyToUser['User']['email']);
             if (!empty($replyToUser['User']['gpgkey'])) {
                 $Email->attachments(array('gpgkey.asc' => array('data' => $replyToUser['User']['gpgkey'])));
             }
             $replyToLog = 'from ' . $replyToUser['User']['email'];
         }
         $Email->from(Configure::read('MISP.email'));
         $Email->to($user['User']['email']);
         $Email->subject($subject);
         $Email->emailFormat('text');
         $result = $Email->send($body);
         $Email->reset();
     }
     $this->Log = ClassRegistry::init('Log');
     $this->Log->create();
     if (!$failed && $result) {
         $this->Log->save(array('org' => 'SYSTEM', 'model' => 'User', 'model_id' => $user['User']['id'], 'email' => $user['User']['email'], 'action' => 'email', 'title' => 'Email ' . $replyToLog . ' to ' . $user['User']['email'] . ' sent, titled "' . $subject . '".', 'change' => null));
         return true;
     } else {
         if (isset($result) && !$result) {
             $failureReason = " there was an error sending the e-mail.";
         }
         $this->Log->save(array('org' => 'SYSTEM', 'model' => 'User', 'model_id' => $user['User']['id'], 'email' => $user['User']['email'], 'action' => 'email', 'title' => 'Email ' . $replyToLog . ' to ' . $user['User']['email'] . ', titled "' . $subject . '" failed. Reason: ' . $failureReason, 'change' => null));
     }
     return false;
 }
Example #23
0
 /**
  * メールを送信する
  *
  * @param string $to 送信先アドレス
  * @param string $title タイトル
  * @param mixed $body 本文
  * @param array $options オプション
  * @return bool 送信結果
  */
 public function sendMail($to, $title = '', $body = '', $options = array())
 {
     $options = array_merge(array('agentTemplate' => true, 'template' => 'default'), $options);
     if (!empty($this->siteConfigs['smtp_host'])) {
         $transport = 'Smtp';
         $host = $this->siteConfigs['smtp_host'];
         $port = $this->siteConfigs['smtp_port'] ? $this->siteConfigs['smtp_port'] : 25;
         $username = $this->siteConfigs['smtp_user'] ? $this->siteConfigs['smtp_user'] : null;
         $password = $this->siteConfigs['smtp_password'] ? $this->siteConfigs['smtp_password'] : null;
         $tls = $this->siteConfigs['smtp_tls'] && $this->siteConfigs['smtp_tls'] == 1;
     } else {
         $transport = 'Mail';
         $host = 'localhost';
         $port = 25;
         $username = null;
         $password = null;
         $tls = null;
     }
     $config = array('transport' => $transport, 'host' => $host, 'port' => $port, 'username' => $username, 'password' => $password, 'tls' => $tls);
     $cakeEmail = new CakeEmail($config);
     // charset
     if (!empty($this->siteConfigs['mail_encode'])) {
         $encode = $this->siteConfigs['mail_encode'];
     } else {
         $encode = 'ISO-2022-JP';
     }
     // ISO-2022-JPの場合半角カナが文字化けしてしまうので全角に変換する
     if ($encode == 'ISO-2022-JP') {
         $title = mb_convert_kana($title, 'KV', "UTF-8");
         if (is_string($body)) {
             $body = mb_convert_kana($body, 'KV', "UTF-8");
         } elseif (isset($body['message']) && is_array($body['message'])) {
             foreach ($body['message'] as $key => $val) {
                 if (is_string($val)) {
                     $body['message'][$key] = mb_convert_kana($val, 'KV', "UTF-8");
                 }
             }
         }
     }
     //CakeEmailの内部処理のencodeを統一したいので先に値を渡しておく
     $cakeEmail->headerCharset($encode);
     $cakeEmail->charset($encode);
     //$format
     if (!empty($options['format'])) {
         $cakeEmail->emailFormat($options['format']);
     } else {
         $cakeEmail->emailFormat('text');
     }
     //bcc 'mail@example.com,mail2@example.com'
     if (!empty($options['bcc'])) {
         // 文字列の場合
         $bcc = array();
         if (is_string($options['bcc'])) {
             if (strpos($options['bcc'], ',') !== false) {
                 $bcc = explode(',', $options['bcc']);
             } else {
                 $bcc[] = $options['bcc'];
             }
             // 配列の場合
         } elseif (is_array($options['bcc'])) {
             $bcc = $options['bcc'];
         }
         foreach ($bcc as $val) {
             if (Validation::email(trim($val))) {
                 $cakeEmail->addBcc($val);
             }
         }
         unset($bcc);
     }
     //cc 'mail@example.com,mail2@example.com'
     if (!empty($options['cc'])) {
         // 文字列の場合
         $cc = array();
         if (is_string($options['cc'])) {
             if (strpos($options['cc'], ',') !== false) {
                 $cc = explode(',', $options['cc']);
             } else {
                 $cc[] = $options['cc'];
             }
             // 配列の場合
         } elseif (is_array($options['cc'])) {
             $cc = $options['cc'];
         }
         foreach ($cc as $val) {
             if (Validation::email(trim($val))) {
                 $cakeEmail->addCc($val);
             }
         }
         unset($cc);
     }
     // to 送信先アドレス (最初の1人がTOで残りがBCC)
     if (strpos($to, ',') !== false) {
         $_to = explode(',', $to);
         $i = 0;
         if (count($_to) >= 1) {
             foreach ($_to as $val) {
                 if ($i == 0) {
                     $cakeEmail->addTo($val);
                     $toAddress = $val;
                 } else {
                     $cakeEmail->addBcc($val);
                 }
                 ++$i;
             }
         }
     } else {
         $cakeEmail->addTo($to);
     }
     // 件名
     $cakeEmail->subject($title);
     //From
     $fromName = $from = '';
     if (!empty($options['from'])) {
         $from = $options['from'];
     } else {
         if (!empty($this->siteConfigs['email'])) {
             $from = $this->siteConfigs['email'];
             if (strpos($from, ',') !== false) {
                 $from = explode(',', $from);
             }
         } else {
             $from = $toAddress;
         }
     }
     if (!empty($options['fromName'])) {
         $fromName = $options['fromName'];
     } else {
         if (!empty($this->siteConfigs['formal_name'])) {
             $fromName = $this->siteConfigs['formal_name'];
         } else {
             $formalName = Configure::read('BcApp.title');
         }
     }
     $cakeEmail->from($from, $fromName);
     //Reply-To
     if (!empty($options['replyTo'])) {
         $replyTo = $options['replyTo'];
     } else {
         $replyTo = $from;
     }
     $cakeEmail->replyTo($replyTo);
     //Return-Path
     if (!empty($options['returnPath'])) {
         $returnPath = $options['returnPath'];
     } else {
         $returnPath = $from;
     }
     $cakeEmail->returnPath($returnPath);
     //$sender
     if (!empty($options['sender'])) {
         $cakeEmail->sender($options['sender']);
     }
     //$theme
     if ($this->theme) {
         $cakeEmail->theme($this->theme);
     }
     if (!empty($options['theme'])) {
         $cakeEmail->theme($options['theme']);
     }
     //viewRender (利用するviewクラスを設定する)
     $cakeEmail->viewRender('BcApp');
     //template
     if (!empty($options['template'])) {
         $layoutPath = $subDir = $plugin = '';
         if ($options['agentTemplate'] && Configure::read('BcRequest.agent')) {
             $layoutPath = Configure::read('BcRequest.agentPrefix');
             $subDir = Configure::read('BcRequest.agentPrefix');
         }
         list($plugin, $template) = pluginSplit($options['template']);
         if ($subDir) {
             $template = "{$subDir}/{$template}";
         }
         if (!empty($plugin)) {
             $template = "{$plugin}.{$template}";
         }
         if (!empty($options['layout'])) {
             $cakeEmail->template($template, $options['layout']);
         } else {
             $cakeEmail->template($template);
         }
         $content = '';
         if (is_array($body)) {
             $cakeEmail->viewVars($body);
         } else {
             $cakeEmail->viewVars(array('body' => $body));
         }
     } else {
         $content = $body;
     }
     // $attachments tmp file path
     $attachments = array();
     if (!empty($options['attachments'])) {
         if (!is_array($options['attachments'])) {
             $attachments = array($options['attachments']);
         } else {
             $attachments = $options['attachments'];
         }
     }
     $cakeEmail->attachments($attachments);
     try {
         $cakeEmail->send($content);
         return true;
     } catch (Exception $e) {
         $this->log($e->getMessage());
         return false;
     }
 }
Example #24
0
 /**
  * Execute!
  */
 public function main()
 {
     $this->timeframe = '-' . (isset($this->params['timeframe']) ? $this->params['timeframe'] : '24 hours');
     // Begin
     $this->out();
     $this->out('Plugin: Forum');
     $this->out('Version: ' . Configure::read('Forum.version'));
     $this->out('Copyright: Miles Johnson, 2010-' . date('Y'));
     $this->out('Help: http://milesj.me/code/cakephp/forum');
     $this->out('Shell: Subscription');
     $this->out();
     $this->out('Queries the database for the latest activity within subscribed topics and forums, then notifies the subscribers with the updates.');
     $this->hr(1);
     // Gather and organize subscriptions
     $topicIds = array();
     $forumIds = array();
     $users = array();
     $count = 0;
     $results = $this->Subscription->find('all', array('contain' => array('User')));
     if (!$results) {
         $this->out('No subscriptions to send...');
         return;
     }
     foreach ($results as $result) {
         $user_id = $result['Subscription']['user_id'];
         $topic_id = $result['Subscription']['topic_id'];
         $forum_id = $result['Subscription']['forum_id'];
         if (empty($users[$user_id])) {
             $users[$user_id] = $result['User'];
             $users[$user_id]['topics'] = array();
             $users[$user_id]['forums'] = array();
         }
         if ($topic_id) {
             $users[$user_id]['topics'][] = $topic_id;
             $topicIds[] = $topic_id;
         }
         if ($forum_id) {
             $users[$user_id]['forums'][] = $forum_id;
             $forumIds[] = $forum_id;
         }
     }
     // Query for the latest topics
     $topics = $this->getTopics($forumIds, $topicIds);
     if (!$topics) {
         $this->out('No new activity...');
         return;
     }
     $settings = Configure::read('Forum.settings');
     $userMap = Configure::read('Forum.userMap');
     $email = new CakeEmail();
     //$email->transport('Debug');
     $email->subject(sprintf(__d('forum', '%s [Subscriptions]'), $settings['name']));
     $email->from($settings['email']);
     $email->replyTo($settings['email']);
     $email->emailFormat('text');
     // Loop over each user and send one email
     foreach ($users as $user) {
         $email->to($user[$userMap['email']]);
         if ($message = $this->formatEmail($user, $topics)) {
             $email->send($message);
             $this->out(sprintf('... %s', $user[$userMap['username']]));
             $count++;
         }
     }
     $this->hr(1);
     $this->out(sprintf('Notified %d user(s)', $count));
 }
Example #25
0
 public function eshopforgetPassword($name, $email, $key)
 {
     $mail_content = $this->getMailContent('FORGOT_PASSWORD');
     // prd($mail_content);
     if (is_array($mail_content) && !empty($mail_content)) {
         $userName = ucwords($name);
         $userEmail = strtolower($email);
         $link = Router::url(array('controller' => 'users', 'action' => 'reset_password', $key), true);
         $mail_refined_content = $mail_content['message'];
         $mail_refined_content = str_replace('{{receiver}}', $name, $mail_refined_content);
         $mail_refined_content = str_replace('{{link}}', $link, $mail_refined_content);
         //   prd($mail_refined_content);
         $admin_email = strtolower(Configure::read('ADMIN_MAIL'));
         App::uses('CakeEmail', 'Network/Email');
         $cake_email = new CakeEmail();
         $cake_email->config('smtp');
         $cake_email->to($userEmail);
         $cake_email->from(array('*****@*****.**' => 'Meocart Team'));
         $cake_email->replyTo("*****@*****.**", "Meocart Team");
         $cake_email->subject($mail_content['subject']);
         $cake_email->template('default', 'default');
         $cake_email->emailFormat('html');
         $cake_email->viewVars(array('content' => $mail_refined_content));
         try {
             $cake_email->send();
         } catch (Exception $e) {
             return false;
         }
         return true;
     }
 }
Example #26
0
/**
 * Send an email using the specified content, template and layout
 *
 * @param string|array $content Either an array of text lines, or a string with contents
 *  If you are rendering a template this variable will be sent to the templates as `$content`
 * @param string $template Template to use when sending email
 * @param string $layout Layout to use to enclose email body
 * @return boolean Success
 */
	public function send($content = null, $template = null, $layout = null) {
		$lib = new CakeEmail();
		$lib->charset = $this->charset;
		$lib->headerCharset = $this->charset;

		$lib->from($this->_formatAddresses((array)$this->from));
		if (!empty($this->to)) {
			$lib->to($this->_formatAddresses((array)$this->to));
		}
		if (!empty($this->cc)) {
			$lib->cc($this->_formatAddresses((array)$this->cc));
		}
		if (!empty($this->bcc)) {
			$lib->bcc($this->_formatAddresses((array)$this->bcc));
		}
		if (!empty($this->replyTo)) {
			$lib->replyTo($this->_formatAddresses((array)$this->replyTo));
		}
		if (!empty($this->return)) {
			$lib->returnPath($this->_formatAddresses((array)$this->return));
		}
		if (!empty($this->readReceipt)) {
			$lib->readReceipt($this->_formatAddresses((array)$this->readReceipt));
		}

		$lib->subject($this->subject)->messageID($this->messageId);
		$lib->helpers($this->_controller->helpers);

		$headers = array('X-Mailer' => $this->xMailer);
		foreach ($this->headers as $key => $value) {
			$headers['X-' . $key] = $value;
		}
		if ($this->date) {
			$headers['Date'] = $this->date;
		}
		$lib->setHeaders($headers);

		if ($template) {
			$this->template = $template;
		}
		if ($layout) {
			$this->layout = $layout;
		}
		$lib->template($this->template, $this->layout)->viewVars($this->_controller->viewVars)->emailFormat($this->sendAs);

		if (!empty($this->attachments)) {
			$lib->attachments($this->_formatAttachFiles());
		}

		$lib->transport(ucfirst($this->delivery));
		if ($this->delivery === 'mail') {
			$lib->config(array('eol' => $this->lineFeed, 'additionalParameters' => $this->additionalParams));
		} elseif ($this->delivery === 'smtp') {
			$lib->config($this->smtpOptions);
		} else {
			$lib->config(array());
		}

		$sent = $lib->send($content);

		$this->htmlMessage = $lib->message(CakeEmail::MESSAGE_HTML);
		if (empty($this->htmlMessage)) {
			$this->htmlMessage = null;
		}
		$this->textMessage = $lib->message(CakeEmail::MESSAGE_TEXT);
		if (empty($this->textMessage)) {
			$this->textMessage = null;
		}

		$this->_header = array();
		$this->_message = array();

		return $sent;
	}
Example #27
0
 public function send_email($dest = null)
 {
     $Email = new CakeEmail('gmail');
     $Email->to($dest);
     $Email->subject('Automagically generated email');
     $Email->replyTo('*****@*****.**');
     $Email->message('teste');
     $Email->from('*****@*****.**');
     $Email->send();
     return $this->redirect(array('action' => 'index'));
 }