Esempio n. 1
0
 protected function sendNotificationEmail($message, $emailParams, $language, $template = 'notification.phtml')
 {
     $emailParams = array_merge($this->_application->get_email_settings(), $emailParams);
     //print_r($emailParams); die();
     $transport = HCMS_Email_TransportFactory::createFactory($emailParams);
     //init view
     $emailView = new Zend_View();
     $emailView->setScriptPath($this->getFrontController()->getModuleDirectory('admin') . '/views/scripts/email_templates/');
     $mvcView = clone Zend_Layout::getMvcInstance()->getView();
     if (isset($mvcView->theme)) {
         $emailView->addScriptPath(APPLICATION_PATH . '/../themes/' . $mvcView->theme . '/views/admin/email_templates/');
     }
     $emailView->assign(array('application' => $this->_application, 'message' => $message, 'lang' => $language, 'serverUrl' => $this->view->serverUrl(), 'imagesUrl' => isset($mvcView->theme) ? $this->view->serverUrl() . '/themes/' . $mvcView->theme . '/images/email/' : $this->view->serverUrl() . '/images/email/'));
     $body = $this->getEmailBody($emailView, $emailParams, $template, $language);
     $mail = new Zend_Mail('UTF-8');
     $mail->setBodyHtml($body);
     $mail->setFrom($emailParams['from_email'], $emailParams['from_name']);
     foreach ($emailParams['to_emails'] as $toEmail) {
         if (is_array($toEmail)) {
             $mail->addTo($toEmail['email'], $toEmail['name']);
         } else {
             $mail->addTo($toEmail);
         }
     }
     $mail->setSubject($this->translate($emailParams['subject']));
     $mail->send($transport);
 }
 protected function sendContactEmail($formValues, array $fields, $language)
 {
     $emailParams = array_merge(array('subject_admin' => 'New Contact Form Submission', 'subject_respond' => 'Thank you for your time', 'template_admin' => 'contact.phtml', 'template_respond' => '%s/contact_auto_respond.phtml', 'layout' => 'layout.phtml'), $this->_globalSettings['email'], $this->_formParams['email']);
     $transport = HCMS_Email_TransportFactory::createFactory($emailParams['sender']);
     //init view
     $emailView = new Zend_View();
     $emailView->setScriptPath($this->getFrontController()->getModuleDirectory('contact') . '/views/scripts/email_templates/');
     $mvcView = clone Zend_Layout::getMvcInstance()->getView();
     if (isset($mvcView->theme)) {
         $emailView->addScriptPath(APPLICATION_PATH . '/../themes/' . $mvcView->theme . '/views/contact/email_templates/');
     }
     $emailView->assign(array('application' => $this->_application, 'data' => $formValues, 'fields' => $fields, 'serverUrl' => $this->view->serverUrl(), 'imagesUrl' => isset($mvcView->theme) ? $this->view->serverUrl() . '/themes/' . $mvcView->theme . '/images/email/' : $this->view->serverUrl() . '/images/email/', 'lang' => $language));
     $body = $this->getEmailBody($emailView, $emailParams, 'template_admin', $language);
     $mail = new Zend_Mail('UTF-8');
     $mail->setBodyHtml($body);
     $mail->setFrom($emailParams['from_email'], $emailParams['from_name']);
     if (!isset($emailParams['disable_admin_email']) || $emailParams['disable_admin_email'] != 'yes') {
         foreach ($emailParams['to_emails'] as $toEmail) {
             $mail->addTo($toEmail['email'], $toEmail['name']);
         }
         $mail->setSubject($this->translate($emailParams['subject_admin']));
         $mail->setReplyTo($formValues['email']);
         $mail->send($transport);
     }
     if ($emailParams['confirmation_email'] == 'yes') {
         $mail->clearRecipients()->clearSubject()->clearReplyTo()->addTo($formValues['email'])->setBodyHtml($this->getEmailBody($emailView, $emailParams, 'template_respond', $language))->setSubject($this->translate($emailParams['subject_respond']));
         if (isset($emailParams['reply_email'])) {
             $mail->setReplyTo($emailParams['reply_email']);
         }
         $mail->send($transport);
     }
 }