public function contactUsAction() { $filters = array('name' => 'StringTrim', 'tel' => 'StringTrim', 'email' => 'StringTrim', 'enquiry' => 'StringTrim'); $validators = array('name' => 'NotEmpty', 'tel' => 'NotEmpty', 'email' => 'NotEmpty', 'enquiry' => 'NotEmpty'); $input = new Zend_Filter_Input($filters, $validators, $_POST); $returnArray = array(); if ($input->isValid()) { $emailer = new Application_Core_Mail(); $params = Zend_Registry::get('params'); $emailer->setTo($params->email->contactUs, 'HomeLet'); $emailer->setFrom($input->email, $input->name); $emailer->setSubject('HomeLet - Contact Us Form'); $bodyHtml = 'Name : ' . $input->name . '<br />'; $bodyHtml .= 'Email : ' . $input->email . '<br />'; $bodyHtml .= 'Tel : ' . $input->tel . '<br />'; $bodyHtml .= 'Enquiry : <pre>' . $input->enquiry . '</pre><br />'; $emailer->setBodyHtml($bodyHtml); if ($emailer->send()) { // Email sent successfully $returnArray['success'] = true; $returnArray['errorMessage'] = ''; } else { $returnArray['success'] = false; $returnArray['errorMessage'] = 'Problem sending email.'; } } else { $returnArray['success'] = false; $returnArray['errorMessage'] = $input->getMessages(); } echo Zend_Json::encode($returnArray); }
public function applyAction() { $this->view->pageTitle = 'Careers'; if ($this->getRequest()->isPost()) { // Handle the cv file and form data $filters = array('name' => 'StringTrim', 'tel' => 'StringTrim', 'email' => 'StringTrim', 'enquiry' => 'StringTrim'); $validators = array('name' => array('NotEmpty', 'messages' => 'Please enter your name'), 'tel' => array('NotEmpty', 'messages' => 'Please enter your telephone number'), 'email' => array('NotEmpty', 'messages' => 'Please enter your email address'), 'enquiry' => array('NotEmpty', 'messages' => 'Please tell us why this position interests you')); $input = new Zend_Filter_Input($filters, $validators, $_POST); if ($input->isValid()) { $upload = new Zend_File_Transfer(); // Make sure the file is actually a document $upload->clearValidators(); $upload->setOptions(array('ignoreNoFile' => true)); //$upload->addValidator('MimeType', false, array('application/msword', 'application/pdf', 'application/rtf', 'text/plain')); if ($upload->isValid()) { $params = Zend_Registry::get('params'); $uploadPath = $params->cms->fileUploadPath; $upload->setDestination($uploadPath); $upload->receive(); $fileInfo = $upload->getFileInfo(); $emailer = new Application_Core_Mail(); $emailer->setTo($params->email->careers, 'HomeLet'); $emailer->setFrom($input->email, $input->name); $emailer->setSubject('HomeLet - Job Application (' . $input->position . ')'); $bodyHtml = 'Position : ' . $input->position . '<br />'; $bodyHtml .= 'Name : ' . $input->name . '<br />'; $bodyHtml .= 'Email : ' . $input->email . '<br />'; $bodyHtml .= 'Tel : ' . $input->tel . '<br />'; $bodyHtml .= 'Enquiry : <pre>' . $input->enquiry . '</pre><br />'; if ($fileInfo['cv_file']['type'] !== null) { $emailer->addAttachment($fileInfo['cv_file']['destination'] . '/' . $fileInfo['cv_file']['name'], $fileInfo['cv_file']['name']); } $emailer->setBodyHtml($bodyHtml); if ($emailer->send()) { $this->_helper->redirector('thanks', 'careers'); } else { } } else { // Invalid file type $this->view->errors = array('cv_file' => 'Invalid file type'); $this->view->name = $input->name; $this->view->tel = $input->tel; $this->view->email = $input->email; $this->view->enquiry = $input->enquiry; } } else { // Invalid form data $this->view->errors = $input->getMessages(); $this->view->name = $input->name; $this->view->tel = $input->tel; $this->view->email = $input->email; $this->view->enquiry = $input->enquiry; } } $careerUrl = $this->getRequest()->getParam('careerID'); $careerID = substr($careerUrl, 0, strpos($careerUrl, '-')); $careers = new Datasource_Cms_Careers(); $career = $careers->getById($careerID); $this->view->title = $career['title']; $this->view->id = $career['id']; }
private function _doMail($data) { $pageSession = new Zend_Session_Namespace('portfolio_insurance_quote'); $customerRefNo = $pageSession->CustomerRefNo; // Get Customer $customerManager = new Manager_Insurance_Portfolio_LegacyCustomer(); $customerObject = new Model_Insurance_Portfolio_LegacyCustomer(); $customerObject = $customerManager->fetchByRefNo($customerRefNo); // Get Properties $propertyManager = new Manager_Insurance_Portfolio_Property(); $properties = array(); // Fetch all the properties related to this customer refNo $properties = $propertyManager->fetchAllProperties($customerRefNo)->toArray(); $propertyHtml = $this->view->partialLoop('portfolio-insurance-quote/partials/email-templates/property-details.phtml', $properties); // Fetch claims releted to this customer refNo $claimsManager = new Manager_Insurance_Portfolio_PreviousClaims(); $claims = $claimsManager->fetchWithClaimTypes($customerRefNo); $claimsHtml = $this->view->partialLoop('portfolio-insurance-quote/partials/email-templates/claims.phtml', $claims); // Fetch bank interest related to this customer refNo $bankInterestManager = new Manager_Insurance_Portfolio_BankInterest(); $bankInterest = $bankInterestManager->fetchAllInterests($customerRefNo); $bankInterestHtml = $this->view->partialLoop('portfolio-insurance-quote/partials/email-templates/bank-interest.phtml', $bankInterest); $uwManager = new Manager_Insurance_Portfolio_UnderwritingAnswers(); $uwAnswers = $uwManager->fetchByRefNo($customerRefNo); // Merge the claim and Interest info into the UW template $uwQuestionsHtml = $this->view->partial('portfolio-insurance-quote/partials/email-templates/uw-questions.phtml', array('claimsHtml' => $claimsHtml, 'bankInterestHtml' => $bankInterestHtml, 'uwAnswers' => $uwAnswers->toArray())); // Merge all the html together $mailBody = $this->view->partial('portfolio-insurance-quote/partials/email-templates/emailQuote.phtml', array('theData' => $data, 'theCustomer' => $customerObject->toArray(), 'propertyHtml' => $propertyHtml, 'uwQuestionsHtml' => $uwQuestionsHtml)); // Get some parameter stuffs $params = Zend_Registry::get('params'); $emailArray = explode(",", $params->email->portfolioAdmin); $toAddress = $emailArray[0]; $ccAddress = $emailArray[1]; $fromAddress = $params->email->noreply; // Mail that bad boy if (isset($data['referred'])) { $referred = " - REFERRED"; } $email = new Application_Core_Mail(); $email->setFrom($fromAddress, "PORTFOLIO NEW BUSINESS {$referred}"); $email->setTo($toAddress, "Underwriting"); $email->setCC($ccAddress); $email->setSubject("Portfolio Website Query - ref: {$customerRefNo}"); $email->setBodyHtml($mailBody); $email->send(); return; }