/** * check customer registration and carry on the registration process if it is not completed * * Returns True if valid, false otherwise. * * @param string $email_address * * @return int */ public function checkRegister($refno, $email, $isChangeEmail) { (string) ($refno = preg_replace('/X/', '', $refno)); $customermgr = new Manager_Core_Customer(); $customer = $customermgr->getCustomerByEmailAddress($email); $params = Zend_Registry::get('params'); $mac = new Application_Core_Security($params->myhomelet->activation_mac_secret, false); $digest = $mac->generate(array('email' => $email)); $activationLink = 'refno=' . $refno . '&' . 'email=' . $email . '&' . 'mac=' . $digest; $customerMap = new Datasource_Core_CustomerMaps(); if ($customer) { if (!$customerMap->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $refno)) { $customermgr->linkLegacyToNew($refno, $customer->getIdentifier(Model_Core_Customer::IDENTIFIER)); } if (!$customer->getEmailValidated()) { $mail = new Application_Core_Mail(); $mail->setTo($email, null); $mail->setFrom('*****@*****.**', 'HomeLet'); $mail->setSubject('My HomeLet account validation'); $mail->applyTemplate('core/account-validation', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $customer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account', 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml'); $mail->applyTextTemplate('core/account-validationtxt', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $customer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml'); // Send email $mail->send(); return 1; } else { return 0; } } else { if ($isChangeEmail) { $cMap = $customerMap->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $refno); if ($cMap) { $customer = $customermgr->getCustomer(Model_Core_Customer::IDENTIFIER, $cMap->getIdentifier()); $customer->setEmailAddress($email); $customermgr->updateCustomer($customer); $legacyids = $customerMap->getLegacyIDs($customer->getIdentifier()); foreach ($legacyids as $legacyid) { if ($legacyid != $refno) { $customer = $customermgr->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $legacyid); $customer->setEmailAddress($email); $customermgr->updateCustomer($customer); } } return 0; } } $oldCustomer = $customermgr->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $refno); $mail = new Application_Core_Mail(); $mail->setTo($email, null); $mail->setFrom('*****@*****.**', 'HomeLet'); $mail->setSubject("Don't forget to register your My HomeLet account"); $mail->applyTemplate('core/partial-registration', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $oldCustomer->getFirstName(), 'templateId' => 'HL2469 12-12', 'heading' => 'Get even more with your My HomeLet account', 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml'); $mail->applyTextTemplate('core/partial-registrationtxt', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $oldCustomer->getFirstName(), 'templateId' => 'HL2469 12-12', 'heading' => 'Get even more with your My HomeLet account'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml'); // Send email $mail->send(); return 2; } }
/** * Send e-mail to agent or agent's master user. * * @param $toEmail * @param $toName * @param $agentEmail * @param $agentFullname * @param $agentSchemeNo * @param $agentUsername * @param $secToken * * @return bool */ protected function _emailPasswordReset($toEmail, $toName, $agentEmail = '', $agentFullname, $agentSchemeNo, $agentUsername, $secToken) { // Get parameters. $params = Zend_Registry::get('params'); // Instantiate and set up an e-mailer object. $emailer = new Application_Core_Mail(); $emailer->setTo($toEmail, $toName); $emailer->setFrom($params->connect->lostlogin->emailFromAddress, $params->connect->lostlogin->emailFromName); $emailer->setSubject($params->connect->lostlogin->emailSubject); $metaData = array('agentFullname' => $agentFullname, 'agentSchemeNo' => $agentSchemeNo, 'agentUsername' => $agentUsername, 'resetLink' => "{$params->url->connectLogin}reset-password?code={$secToken}"); $emailer->applyTemplate('connect_lostLogin', $metaData, false, '/email-branding/homelet/generic-with-signature-footer.phtml'); return $emailer->send(); }
/** * Sends a single email to a customer to provide a validation URL for activating a registered My HomeLet account. * * @param string $subject * @param string $heading * @param string $template * @param string $templateTxt * @param string $templateId * @return void */ public function sendAccountValidationEmail($subject = self::VALIDATION_SUBJECT, $heading = self::VALIDATION_HEADING, $template = self::VALIDATION_TEMPLATE, $templateTxt = self::VALIDATION_TEMPLATETXT, $templateId = self::VALIDATION_TEMPLATEID) { $params = Zend_Registry::get('params'); // Create sign-up completion email $mail = new Application_Core_Mail(); $mail->setTo($this->getEmailAddress(), null); $mail->setFrom('*****@*****.**', 'HomeLet'); $mail->setSubject($subject); // Generate activation link $mac = new Application_Core_Security($params->myhomelet->activation_mac_secret, false); $digest = $mac->generate(array('email' => $this->getEmailAddress())); $activationLink = sprintf('email=%s&mac=%s', urlencode($this->getEmailAddress()), $digest); // Apply template $mail->applyTemplate($template, array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $this->getFirstName(), 'templateId' => $templateId, 'heading' => $heading, 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml'); $mail->applyTextTemplate($templateTxt, array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $this->getFirstName(), 'templateId' => $templateId, 'heading' => $heading), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml'); // Send email $mail->send(); }
/** * Register action * * @return void */ public function partialRegistrationAction() { $this->_setBreadcrumbs(array('/' => 'Home', '/my-homelet' => 'My HomeLet', '/my-homelet/partial-registration' => 'Continue Registration')); $params = Zend_Registry::get('params'); $form = new Account_Form_Register(); // Populate the form with the security question options $securityQuestionModel = new Datasource_Core_SecurityQuestion(); $securityQuestionOptions = $securityQuestionModel->getOptions(); foreach ($securityQuestionOptions as $option) { $form->security_question->addMultiOption($option['id'], $option['question']); } $customerManager = new Manager_Core_Customer(); if (!$this->getRequest()->isPost()) { $refno = $_GET['refno']; $email = $_GET['email']; $mac = new Application_Core_Security($params->myhomelet->activation_mac_secret, false); $digest = $mac->generate(array('email' => $email)); if ($refno) { // Try by legacy customer refno $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $refno); } else { // Try by email $customer = $customerManager->getCustomerByEmailAddress($email); } $formData = array(); $formData['title'] = $customer->getTitle(); $formData['first_name'] = $customer->getFirstName(); $formData['last_name'] = $customer->getLastName(); $formData['email'] = $email; $formData['refno'] = $refno; #$form->title->setAttrib('readonly','readonly'); #$form->first_name->setAttrib('readonly','readonly'); #$form->last_name->setAttrib('readonly','readonly'); $form->email->setAttrib('readonly', 'readonly'); $form->populate($formData); if ($digest != $_GET['mac']) { // Render error page if invalid mac $this->render('activate-account-invalidmac'); return; } } else { if ($form->isValid($this->getRequest()->getPost())) { // Detect if the customer has already registered with this email address $customer = $customerManager->getCustomerByEmailAddress($form->email->getValue()); if ($customer) { // Customer already exists, flag form in error // Ideally this should go in the form as an overridden validation method, but this would // tightly couple the form to the customer manager anyway, which itself is bad. // Alternatively I could inject the found customer object into the form, but then this doesn't change // much to using the code here anyway. $form->email->addError('This email is already in use. Have you signed up before?')->markAsError(); } else { // Create customer. Because this is the generic registration page, we use a generic customer type $customer = $customerManager->createCustomerFromLegacy($form->email->getValue(), $form->refno->getValue()); $custID = $customer->getIdentifier(Model_Core_Customer::IDENTIFIER); $leg = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $form->refno->getValue()); // Update customer with password and security data $customerManager->updateCustomerByLegacy($leg, $custID); $customer = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $custID); $customer->setSecurityQuestion($form->security_question->getValue()); $customer->setSecurityAnswer($form->security_answer->getValue()); $customer->setPassword($form->password->getValue()); $customer->setEmailValidated(true); $customerManager->updateCustomer($customer); // Create welcome email $mail = new Application_Core_Mail(); $mail->setTo($_GET['email'], null); $mail->setFrom('*****@*****.**', 'HomeLet'); $mail->setSubject('Registration for My HomeLet'); // Apply template $mail->applyTemplate('core/account-welcome', array('homeletWebsite' => $params->homelet->domain, 'templateId' => 'HL2443 12-12', 'firstname' => $customer->getFirstName(), 'heading' => 'Your registration for My HomeLet is complete!', 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml'); $mail->applyTextTemplate('core/account-welcometxt', array('homeletWebsite' => $params->homelet->domain, 'templateId' => 'HL2443 12-12', 'firstname' => $customer->getFirstName(), 'heading' => 'Your registration for My HomeLet is complete!'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml'); // Send email $mail->send(); // Find all customers in mysql4 insurance that have the same email address $legacyCustomers = $customerManager->getAllLegacyCustomersByEmailAddress($_GET['email']); $customerIdentifier = $customer->getIdentifier(Model_Core_Customer::IDENTIFIER); foreach ($legacyCustomers as $legacyCustomer) { // For each customer found, insert a record into the mysql5 customer_legacy_customer_map table $legacyIdentifier = $legacyCustomer->getIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER); $customerMap = new Datasource_Core_CustomerMaps(); if (!$customerMap->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $legacyIdentifier)) { $customerManager->linkLegacyToNew($legacyIdentifier, $customerIdentifier); } } $this->_helper->redirector->gotoUrl('/my-homelet/login?message=registration-complete'); } } } $this->view->form = $form; }
/** * Initialise the step 3 form [Important Information Form] * * @return void */ public function step3Action() { $pageForm = new TenantsInsuranceQuoteB_Form_Step3(); // Tell page to use AJAX validation as we go $this->view->headScript()->appendScript('var ajaxValidate = true; var ajaxValidatePage = 3;'); // Get customer details $customerManager = new Manager_Core_Customer(); $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $this->_customerReferenceNumber); // Hydrate registration form if (isset($pageForm->subform_register) || isset($pageForm->subform_login)) { // Grab a new customer to populate the form $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); $newCust = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $pageSession->CustomerID); if (isset($pageForm->subform_register)) { if ($newCust) { $pageForm->subform_register->email->setValue($newCust->getEmailAddress()); $pageForm->subform_register->security_question->setValue($newCust->getSecurityQuestion()); $pageForm->subform_register->security_answer->setValue($newCust->getSecurityAnswer()); $emailAddress = $newCust->getEmailAddress(); } else { $pageForm->subform_register->email->setValue($customer->getEmailAddress()); $emailAddress = $customer->getEmailAddress(); } if (!$emailAddress) { $emailAddress = $newCust->getEmailAddress(); } } else { if ($newCust) { $pageForm->subform_login->email->setValue($newCust->getEmailAddress()); } } } if ($this->getRequest()->isPost()) { $valid = $this->_formStepCommonValidate($pageForm, 3); if (isset($pageForm->subform_register)) { $pageForm->subform_register->getElement('email')->setValue($emailAddress); } if ($valid) { $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); $pageSession->IsNewCustomer = false; $data = $pageForm->getValues(); //Update the WebLead summary and create a STEP3 blob. $webLeadManager = new Manager_Core_WebLead(); $webLeadSummary = $webLeadManager->getSummary($this->_webLeadSummaryId); $webLeadSummary->lastUpdatedTime = $this->_offsetDate(); $webLeadSummary->promotionCode = $data["subform_howhear"]['campaign_code']; $webLeadManager->updateSummary($webLeadSummary); //Determine if a new STEP3 blob needs to be created, or an existing one retrieved. if ($webLeadManager->getBlobExists($this->_webLeadSummaryId, Model_Core_WebLeadStep::STEP3)) { $webLeadBlob = $webLeadManager->getBlob($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP3); } else { $webLeadBlob = $webLeadManager->createNewBlob($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP3); } //Update the blob and store $webLeadBlob->blob = Zend_Json::encode($_POST); $webLeadBlob->blobChecksum = crc32($webLeadBlob->blob); $webLeadManager->updateBlob($webLeadBlob); // Instantiate the quote manager $quoteManager = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $this->_policyNumber); // Save new ASN if there is one // Create a postcode model $postcode = new Manager_Core_Postcode(); // Get the address as array for Insured and correspondance address $insuredAddress = $postcode->getPropertyByID($data['subform_insuredaddress']['ins_address'], false); $correspondenceAddress = $postcode->getPropertyByID($data['subform_correspondencedetails']['cor_address'], false); // Update the property address in the quote $quoteManager->setPropertyAddress(($insuredAddress['organisation'] != '' ? "{$insuredAddress['organisation']}, " : '') . ($insuredAddress['buildingName'] != '' ? "{$insuredAddress['buildingName']}, " : '') . ($insuredAddress['houseNumber'] != '' ? "{$insuredAddress['houseNumber']} " : '') . $insuredAddress['address2'], $insuredAddress['address4'], $insuredAddress['address5'], $insuredAddress['postcode']); // Update start and end dates $startDate = $data['subform_policydetails']['policy_start']; $startDate = substr($startDate, 6, 4) . '-' . substr($startDate, 3, 2) . '-' . substr($startDate, 0, 2); $endDate = date('Y-m-d', strtotime(date('Y-m-d', strtotime($startDate)) . ' +1 year -1 day')); $quoteManager->setStartAndEndDates($startDate, $endDate); //Update the customer in the DataStore and the LegacyDataStore. Use the CustomerManager //to do this. //$customerManager = new Manager_Core_Customer(); //First get the existing customer details. //$customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $this->_customerReferenceNumber); //Now modify the details. $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, ($correspondenceAddress['organisation'] != '' ? "{$correspondenceAddress['organisation']}, " : '') . ($correspondenceAddress['houseNumber'] != '' ? "{$correspondenceAddress['houseNumber']} " : '') . ($correspondenceAddress['buildingName'] != '' ? "{$correspondenceAddress['buildingName']}, " : '') . $correspondenceAddress['address2']); $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $correspondenceAddress['address4']); $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $correspondenceAddress['address5']); $customer->setPostCode($correspondenceAddress['postcode']); $customer->setDateOfBirthAt(Application_Core_Utilities::ukDateToMysql($pageSession->CustomerDob)); //Finally, save the details back to both DataStores. $customerManager->updateCustomer($customer); $premiums = $quoteManager->calculatePremiums(); // Save MI information - how did you hear about us $marketQuestion = new Manager_Core_ManagementInformation(); $marketQuestion->saveMarketingAnswers($this->_policyNumber, $this->_customerReferenceNumber, $data["subform_howhear"]["how_hear"]); // Perform login/register procedure $auth = Zend_Auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer')); if (isset($data['subform_register'])) { // Process registration $params = Zend_Registry::get('params'); $newCustomer = $customerManager->getCustomerByEmailAddress($data['subform_register']['email']); if (!$newCustomer) { $newCustomer = $customerManager->createCustomerFromLegacy($data['subform_register']['email'], $this->_customerReferenceNumber); } // Update customer with password and security data $newCustomer->setTitle($customer->getTitle()); $newCustomer->setFirstName($customer->getFirstName()); $newCustomer->setLastName($customer->getLastName()); $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, ($correspondenceAddress['organisation'] != '' ? "{$correspondenceAddress['organisation']}, " : '') . ($correspondenceAddress['houseNumber'] != '' ? "{$correspondenceAddress['houseNumber']} " : '') . ($correspondenceAddress['buildingName'] != '' ? "{$correspondenceAddress['buildingName']}, " : '') . $correspondenceAddress['address2']); $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $correspondenceAddress['address4']); $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $correspondenceAddress['address5']); $newCustomer->setPostCode($correspondenceAddress['postcode']); $newCustomer->setDateOfBirthAt(Application_Core_Utilities::ukDateToMysql($pageSession->CustomerDob)); // assuming that the email is already set and so won't require setting again. // $newCustomer->setEmailAddress($data['subform_register']['email']); $newCustomer->setSecurityQuestion($data['subform_register']['security_question']); $newCustomer->setSecurityAnswer($data['subform_register']['security_answer']); $newCustomer->setPassword($data['subform_register']['password']); $newCustomer->setAccountLoadComplete(true); $newCustomer->typeID = Model_Core_Customer::CUSTOMER; $customerManager->updateCustomer($newCustomer); // Create sign-up completion email $mail = new Application_Core_Mail(); $mail->setTo($data['subform_register']['email'], null); $mail->setFrom('*****@*****.**', 'HomeLet'); $mail->setSubject('My HomeLet account validation'); // Generate activation link $mac = new Application_Core_Security($params->myhomelet->activation_mac_secret, false); $digest = $mac->generate(array('email' => $data['subform_register']['email'])); $activationLink = 'email=' . $data['subform_register']['email'] . '&' . 'mac=' . $digest; // Apply template $mail->applyTemplate('core/account-validation', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $newCustomer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account'), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml'); $mail->applyTextTemplate('core/account-validationtxt', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $newCustomer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml'); // Send email $mail->send(); // Everything has been saved ok so navigate to next step $this->_formStepCommonNavigate(3); } elseif ($auth->hasIdentity()) { $this->_formStepCommonNavigate(3); } //return; } elseif (isset($_POST['back'])) { $this->_formStepCommonNavigate(3); return; } } // Load the element data from the database if we can if ($this->_formStepCommonPopulate($pageForm, 3)) { // Render the page unless we have been redirected $this->view->form = $pageForm; $this->render('step'); } }
/** * This method is called when the Reference Subject completes an email link. */ public function emailLinkEndAction() { $session = new Zend_Session_Namespace('referencing_global'); $params = Zend_Registry::get('params'); $referenceManager = new Manager_Referencing_Reference(); $reference = $referenceManager->getReference($session->referenceId); $customerId = $reference->customer->customerId; $customerManager = new Manager_Core_Customer(); $customer = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $customerId); $customerEmail = $customer->getEmailAddress(); $recipientName = $customer->getFirstName() . ' ' . $customer->getLastName(); //Generate the security token to be appended to the URL. $hashingString = $params->pll->emailLink->security->securityString; $securityManager = new Manager_Core_Security($hashingString); $customerToken = $securityManager->generate(array('refNo' => $reference->externalId, 'customerId' => $customerId)); //Prepare the meta data. $metaData = array(); $metaData['firstName'] = $customer->getFirstName(); $metaData['lastName'] = $customer->getLastName(); $metaData['linkUrl'] = $params->pll->emailLink->email->linkEndUrl; $metaData['linkUrl'] .= '?'; $metaData['linkUrl'] .= "refNo={$reference->externalId}"; $metaData['linkUrl'] .= '&'; $metaData['linkUrl'] .= "customerToken={$customerToken}"; //Send email to landlords $emailer = new Application_Core_Mail(); $emailer->setTo($customerEmail, $recipientName); //Set the email from details. $emailFrom = $params->pll->emailLink->email->from; $emailFromName = $params->pll->emailLink->email->fromname; $emailer->setFrom($emailFrom, $emailFromName); //Set the subject line $addressLine1 = $reference->propertyLease->address->addressLine1; $town = $reference->propertyLease->address->town; $postCode = $reference->propertyLease->address->postCode; $emailer->setSubject("Re: {$addressLine1}, {$town}, {$postCode}"); //Apply template and send. $emailer->applyTemplate('landlordsreferencing_emaillinkend', $metaData, false); $emailer->send(); //Delete session unset($session->userType); unset($session->referenceId); $this->view->fractionComplete = 95; }
/** * Sends an initial notification to the reference subject (tenant or guarantor). * * The initital notification sent to the reference subject advises them that their * reference is on the system and they can track it. * * @param mixed $enquiryId * The unique Enquiry identifier (internal or external). May be integer or string. * * @return boolean * Returns true on succesful sending of the notification, false otherwise. */ public function sendTatInvitation() { //Get the general parameters. $params = Zend_Registry::get('params'); $metaData = array(); $emailFromName = $params->tat->email->fromname; $emailFrom = $params->tat->email->from; $emailSubject = $params->tat->email->subject; $metaData['tatUrl'] = $params->url->tenantsTrackApplicationFromEmail; $metaData['homeLetUrl'] = $params->homelet->domain . '/'; // Ensure enquiry ID given out is an internal one $metaData['tenantIrn'] = $this->_reference->internalId; //Set the destination email address. $referenceSubjectContact = $this->_reference->referenceSubject->contactDetails; if (!empty($referenceSubjectContact->email1)) { $emailTo = $referenceSubjectContact->email1; } else { if (!empty($referenceSubjectContact->email2)) { $emailTo = $referenceSubjectContact->email2; } else { return false; } } //Set the reference subject name into the email body. $referenceSubjectName = $this->_reference->referenceSubject->name; $referenceSubjectNameString = $referenceSubjectName->firstName . ' ' . $referenceSubjectName->lastName; $metaData['tenantName'] = $referenceSubjectNameString; //Set the property address into the email body. $propertyAddress = $this->_reference->propertyLease->address; $propertyAddressString = ''; $propertyAddressString .= $propertyAddress->addressLine1 != '' ? "{$propertyAddress->addressLine1}\n" : ''; $propertyAddressString .= $propertyAddress->addressLine2 != '' ? "{$propertyAddress->addressLine2}\n" : ''; $propertyAddressString .= $propertyAddress->town != '' ? "{$propertyAddress->town}\n" : ''; $propertyAddressString .= $propertyAddress->postCode != '' ? "{$propertyAddress->postCode}\n" : ''; $metaData['propertyAddress'] = nl2br(substr($propertyAddressString, 0, -1)); $metaData['propertyAddressTxt'] = $propertyAddressString; //Put the letting agent name and ASN into the email body. if ($this->_reference->customer->customerType == Model_Referencing_CustomerTypes::LANDLORD) { $agentId = $params->homelet->defaultAgent; } else { $agentId = $this->_reference->customer->customerId; } $agentDatasource = new Datasource_Core_Agents(); $lettingAgent = $agentDatasource->getAgent($agentId); $lettingAgentNameString = $lettingAgent->name; $metaData['lettingAgentName'] = $lettingAgentNameString; $metaData['lettingAgentAsn'] = $lettingAgent->agentSchemeNumber; //Prepare the email. $emailer = new Application_Core_Mail(); $emailer->setTo($emailTo, $emailFromName); $emailer->setFrom($emailFrom, $emailFromName); $emailer->setSubject($emailSubject); $emailer->applyTemplate('tenants_tatInvitation', $metaData, false, '/email-branding/homelet/generic-with-signature-footer.phtml'); $emailer->applyTextTemplate('tenants_tatInvitationTxt', $metaData, false, '/email-branding/homelet/generic-with-signature-footer-txt.phtml'); //Send, update and return $success = $emailer->send(); if ($success) { //Update the notification log. $tatInvitationDatasource = new Datasource_Referencing_TatInvitation(); $tatInvitationDatasource->insertInvitation($this->_reference->externalId); $returnVal = true; } else { $returnVal = false; } return $returnVal; }
/** * To send a confirmation email after the completion of step4 * * @return void */ public function sendConfirmationEmail($refNumber, $khClaimNumber) { // get agent name and claim number to send an confirmation email $claimData = $this->getClaim($refNumber); $emailer = new Application_Core_Mail(); $emailer->setTo($claimData->getAgentEmail(), $claimData->getAgentName()); $emailer->setFrom('*****@*****.**', 'Homelet Claim Submission'); $emailer->setSubject('ASN: ' . $claimData->getAgentSchemeNumber() . '; Claim Ref: ' . $khClaimNumber); $metaData = array('agentname' => $claimData->getAgentName(), 'propertyAddress' => $claimData->getTenancyAddress(), 'claimNumber' => $khClaimNumber); $emailer->applyTemplate('connect_claimSubmitConfirmation', $metaData, false, '/email-branding/homelet/generic-with-signature-footer.phtml'); return $emailer->send(); }
/** * Send a notification email to all agents for the required reporting month/year * * @param int $agentSchemeNumber * @param string $email_address * @param string $month * @param string $year * @return bool */ public function sendEmailNotification($agentSchemeNumber, $email_address, $month, $year) { echo "Send email to agent {$agentSchemeNumber} - {$email_address}\n"; $params = Zend_Registry::get('params'); $mail = new Application_Core_Mail(); $mail->setTo($email_address, null); $mail->setFrom('*****@*****.**', 'HomeLet'); $mail->setSubject('Your statement is ready for you'); // Apply template $mail->applyTemplate('core/invoice-notification', array('asn' => $agentSchemeNumber, 'year' => $year, 'month' => $month, 'heading' => 'STATEMENT NOTIFICATION', 'templateId' => '', 'homeletWebsite' => $params->homelet->domain, 'connectURL' => $params->connectUrl->connectRootUrl, 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-templates/core/footer.phtml', '/email-templates/core/header.phtml'); // Send email if (!$mail->send()) { echo 'Message could not be sent to ' . $email_address - 'Mailer Error: ' . $mail->ErrorInfo; } return true; }