/**
  * Sends a notification email to underwriting with referral details.
  *
  * This method provides a convenient way of notifying underwriting when
  * a customer has failed the underwriting critera during a quote, MTA or
  * renewal.
  *
  * @param string $policyNumber
  * The quote/policynumber to include in the email.
  *
  * @param string $refNo
  * The customer reference number to include in the email.
  *
  * @return boolean
  * Returns true if the email was successfully sent, false otherwise.
  */
 public function notifyUnderwriting($policyNumber, $refNo)
 {
     //Get the necessary parameters.
     $params = Zend_Registry::get('params');
     $emailTo = $params->uw->re->to;
     $emailFromName = $params->uw->re->fromname;
     $emailFrom = $params->uw->re->from;
     $emailSubject = $params->uw->re->subject;
     if ('Other' === $this->_reason) {
         $emailBody = $params->uw->re->other_body;
     } else {
         $emailBody = $params->uw->re->body;
     }
     //Prepare the email.
     $emailer = new Application_Core_Mail();
     $emailer->setTo($emailTo, $emailFromName);
     $emailer->setFrom($emailFrom, $emailFromName);
     $emailSubject = preg_replace("/\\[--POLNO--\\]/", $policyNumber, $emailSubject);
     $emailer->setSubject($emailSubject);
     $emailBody = preg_replace("/\\[--POLNO--\\]/", $policyNumber, $emailBody);
     $emailBody = preg_replace("/\\[--REFNO--\\]/", $refNo, $emailBody);
     $emailer->setBodyText($emailBody);
     $success = $emailer->send();
     if ($success) {
         //Update the notification log.
         $underwritingEmailLog = new Datasource_Core_UnderwritingEmailLog();
         $underwritingEmailLog->insertNotification(new Zend_Date(), $policyNumber, $emailBody);
     }
     return $success;
 }
 public function emailCompanyWithAttachments($toAddress, $content, $filename)
 {
     $emailer = new Application_Core_Mail();
     $emailer->setTo($toAddress, $toAddress);
     $emailer->setFrom('*****@*****.**', '*****@*****.**');
     $emailer->setSubject('Company Application');
     $emailer->setBodyText($content);
     // Attach all files from detailAttachments
     $emailer->addAttachment($filename, substr($filename, strrpos($filename, '/') + 1));
     // Send and set returnval
     $success = $emailer->send();
     if ($success) {
         $returnVal = true;
     } else {
         $returnVal = false;
     }
     return $returnVal;
 }
Example #3
0
 /**
  * Opens a PDF from local storage, populates it with agent details (if
  * needed) and outputs it to either browser or by e-mail.
  *
  * @param string $formName The name of the PDF form, or 'all' for all by e-mail.
  * @param mixed $asn Agent scheme number of agent whose details are to be inserted.
  * @param int $agentUserId Optional user ID - needed for e-mailing forms.
  * @param string $destination Optional output mechanism, if set should be 'browser' or not 'browser'.
  * @param mixed $refno Optional reference number, for a special case PDF that requires applicant data injection.
  */
 public function populateAndOuput($formName, $asn, $agentUserId = null, $destination = 'browser', $refno = null)
 {
     $attachmentList = array();
     switch ($formName) {
         // Forms that require agent details to be injected
         case 'Agent-Company':
         case 'Agent-Guarantor':
         case 'Agent-Individual':
         case 'Agent-Student-guarantor':
         case 'Agent-Unemployed-guarantor':
             // Instantiate agent manager and fetch agent details
             $agentManager = new Manager_Core_Agent();
             $agent = $agentManager->getAgent($asn);
             // Shove agent details through form
             $this->setForm($formName);
             $this->agentPopulate($agent);
             // For "Print Guarantor Form" from ref summary screen:
             if (!is_null($refno)) {
                 // Fetch reference by refno using the Referencing MUNT Manager class
                 $refMuntManager = new Manager_ReferencingLegacy_Munt();
                 $reference = $refMuntManager->getReference($refno);
                 // For safety, ensure reference belongs to this ASN before injecting applicant details
                 if ($reference->customer->customerId == $asn) {
                     $this->applicantPopulate($reference);
                 }
             }
             if ($destination == 'browser') {
                 $this->output('browser');
             } else {
                 $attachmentList[$formName] = $this->output('file');
             }
             break;
             // Forms that are a pass-through
         // Forms that are a pass-through
         case 'Tenant-Declaration':
         case 'Guarantor-Declaration':
             $this->setForm($formName);
             if ($destination == 'browser') {
                 $this->output('browser');
             } else {
                 $attachmentList[$formName] = $this->output('file');
             }
             break;
             // Send all forms - by e-mail only
         // Send all forms - by e-mail only
         case 'all':
             // Instantiate agent manager and fetch agent details
             $agentManager = new Manager_Core_Agent();
             $agent = $agentManager->getAgent($asn);
             // Generate those needing agent data merged in
             foreach (array('Agent-Company', 'Agent-Guarantor', 'Agent-Individual', 'Agent-Student-guarantor', 'Agent-Unemployed-guarantor') as $thisFormName) {
                 $this->setForm($thisFormName);
                 $this->agentPopulate($agent);
                 $attachmentList[$thisFormName] = $this->output('file');
             }
             // Generate straight throughs
             foreach (array('Tenant-Declaration', 'Guarantor-Declaration') as $thisFormName) {
                 $this->setForm($thisFormName);
                 $attachmentList[$thisFormName] = $this->output('file');
             }
             break;
     }
     // If there are attachments, this is/these are to be sent by e-mail
     if (count($attachmentList) > 0) {
         // Instantiate agent user manager to get name and e-mail address
         $agentUserManager = new Manager_Core_Agent_User();
         $agentUser = $agentUserManager->getUser($agentUserId);
         // Generate e-mail
         $mailer = new Application_Core_Mail();
         $mailer->setTo($agentUser->email->emailAddress, $agentUser->name);
         // TODO: Parameterise:
         $mailer->setFrom('*****@*****.**', 'HomeLet Referencing');
         $mailer->setSubject('HomeLet Referencing Application Form');
         $mailer->setBodyText('Please find your HomeLet referencing application forms attached.');
         foreach ($attachmentList as $name => $location) {
             $mailer->addAttachment($location, "{$name}.pdf");
         }
         $mailer->send();
         // Garbage collection
         $this->garbageCollect($attachmentList);
     }
 }
Example #4
0
 /**
  * Sends an email to 'The Campaign Team' who are responsible for calling back the reference subject.
  *
  * Does not provide support for attachments, so should be used where the reference
  * subject (tenant or guarantor) has not provided one.
  * 
  * @param mixed $enquiryId
  * The unique Enquiry identifier (internal or external). May be integer or string.
  *
  * @param string $content
  * The content of the message sent by the reference subject.
  *
  * @return boolean
  * Returns true on successful send, false otherwise.
  */
 public function notifyCampaignTeam($content)
 {
     $emailer = new Application_Core_Mail();
     $emailer->setTo('*****@*****.**', 'Campaign Team');
     $emailer->setFrom('*****@*****.**', 'Tenant Tracker');
     $emailer->setSubject('Tenant Tracker Quote');
     $emailer->setBodyText($content);
     //Send and return
     $success = $emailer->send();
     if ($success) {
         $returnVal = true;
     } else {
         $returnVal = false;
     }
     return $returnVal;
 }
Example #5
0
 /**
  * Sends an email to 'Claim Handler' with attachments
  *
  * @param int $claimRefNo
  * @param String $content
  * @param int $agentSchemeNumber
  * @param int $attachment
  * @param String $agentEmail
  * Provides support for attachments, automatically including any uploaded by the
  * reference subject.
  *
  * @return boolean
  * Returns true on successful send, false otherwise.
  */
 public function notifyEmailHandlerWithAttachments($claimRefNo, $content, $agentSchemeNumber, $attachment, $agentEmail)
 {
     // Fetch params from registry for default From address
     $this->_params = Zend_Registry::get('params');
     $emailer = new Application_Core_Mail();
     $keyHouseClaimManager = new Datasource_Insurance_KeyHouse_Claim();
     $keyHouseClaimManager = $keyHouseClaimManager->getClaim($claimRefNo, $agentSchemeNumber);
     $getClaimHandler = $keyHouseClaimManager[0]['ClaimsHandlerEmail'];
     $emailer->setTo($getClaimHandler, 'KHDBView');
     $emailer->setFrom($this->_params->homelet->defaultEmailAddress, 'Online Claims');
     $emailer->setSubject('ASN:' . $agentSchemeNumber . ';' . 'Claim Ref:' . $claimRefNo);
     $setBodyContent = '';
     $setBodyContent .= "ASN: {$agentSchemeNumber} \r\n\r\n";
     $setBodyContent .= "Claim Ref No: {$claimRefNo} \r\n\r\n";
     $setBodyContent .= "Contact e-mail: {$agentEmail}\r\n\r\n";
     $setBodyContent .= $content;
     $emailer->setBodyText($setBodyContent);
     $claimDir = explode('/', $claimRefNo);
     if ($attachment == 1) {
         // Attach all files from detailAttachments
         foreach (array_keys($this->detailAttachments($claimDir[1], $agentSchemeNumber)) as $filename) {
             $emailer->addAttachment($filename, substr($filename, strrpos($filename, '/') + 1));
         }
     }
     // Send and set returnval
     $success = $emailer->send();
     if ($success) {
         $returnVal = true;
     } else {
         $returnVal = false;
     }
     return $returnVal;
 }
 public function sendPdfAction()
 {
     // Check user is logged in to get ASN from
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('hl_connect'));
     if ($auth->hasIdentity()) {
         // Fetch ASN and agent user ID
         $asn = $auth->getStorage()->read()->agentschemeno;
         $userId = $auth->getStorage()->read()->agentid;
         $request = $this->getRequest();
         if (!is_null($request->getParam('filename'))) {
             $filename = $request->getParam('filename');
             // Is this a special agent application form that requires content injection and is sent to a specific agent user?
             if (preg_match('/agent-form\\?form=([\\w\\-]+)$/i', $filename, $matches) > 0) {
                 // Yes, requires agent content injection and sending
                 $formName = $matches[1];
                 $agentFormManager = new Manager_Connect_AgentForm();
                 $agentFormManager->populateAndOuput($formName, $asn, $userId, 'email');
                 echo "{\"successMessage\":\"Email sent\"}\n";
                 exit;
             } else {
                 // Standard PDF, load and send as-is
                 $filters = array('*' => array('StringTrim', 'HtmlEntities', 'StripTags'));
                 // Check e-mail present and valid
                 $formInput['to'] = htmlentities($request->getParam('to'));
                 $formInput['message'] = htmlentities($request->getParam('message'));
                 $formInput['filename'] = htmlentities($request->getParam('filename'));
                 $emailValidator = new Zend_Validate_EmailAddress();
                 $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Domain name invalid in email address', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid email address'));
                 $validators = array('*' => array('allowEmpty' => true), 'email' => $emailValidator);
                 $validate = new Zend_Filter_Input($filters, $validators, $formInput);
                 if ($validate->isValid()) {
                     // Security - ensure PDF can only be requested from public webspace
                     $params = Zend_Registry::get('params');
                     $realpath = realpath($params->connect->basePublicPath . $validate->filename);
                     if (strpos($realpath, $params->connect->safePublicRealPathContains) !== false && strtolower(substr($realpath, -4, 4)) == '.pdf') {
                         // Generate e-mail
                         $mailer = new Application_Core_Mail();
                         $mailer->setTo($validate->to, $validate->to);
                         // TODO: Parameterise:
                         $mailer->setFrom('*****@*****.**', 'HomeLet');
                         $mailer->setSubject("{$validate->filename} sent by HomeLet");
                         $mailer->setBodyText($validate->message);
                         $mailer->addAttachment($realpath, $validate->filename);
                         $mailer->send();
                         echo "{\"successMessage\":\"Email sent\"}\n";
                         exit;
                     }
                 } else {
                     echo "{\"errorMessage\":\"Invalid e-mail address\"}\n";
                     exit;
                 }
             }
         } else {
             echo "{\"errorMessage\":\"No PDF specified\"}\n";
             exit;
         }
     }
     echo "{\"errorMessage\":\"There was an error, please try again later\"}\n";
 }