/** * Send mail * * @access private * @param string $userEmail * @param bool $editFlag * @throws \Exception From email is not set * @throws \Exception To email is not set */ private function sendMail($userEmail, $editFlag) { $forceFlush = APPLICATION_ENV == "production" ? false : true; $cachedSystemData = $this->systemCacheHandler->getCachedSystemData($forceFlush); $settings = $cachedSystemData[CacheHandler::SETTINGS_KEY]; if (array_key_exists(Settings::SYSTEM_EMAIL, $settings)) { $from = $settings[Settings::SYSTEM_EMAIL]; } if (array_key_exists(Settings::ADMIN_EMAIL, $settings)) { $to = $settings[Settings::ADMIN_EMAIL]; } if (!isset($from)) { throw new \Exception("From email is not set"); } if (!isset($to)) { throw new \Exception("To email is not set"); } $templateParameters = array("email" => $userEmail); if ($editFlag === false) { $templateName = MailTempates::NEW_COURSE_NOTIFICATION_TEMPLATE; $subject = MailSubjects::NEW_COURSE_NOTIFICATION_SUBJECT; } else { $templateName = MailTempates::UPDATED_COURSE_NOTIFICATION_TEMPLATE; $subject = MailSubjects::UPDATED_COURSE_NOTIFICATION_SUBJECT; } $mailArray = array('to' => $to, 'from' => $from, 'templateName' => $templateName, 'templateParameters' => $templateParameters, 'subject' => $subject); $this->notification->notify($mailArray); }
/** * function meant to send 2 emails one to admin * and the other to tvtc * @param int $request * @param string $to * @param bool $notificationEmailFlag ,default is false * @throws \Exception From email is not set */ private function sendMail($request, $to, $notificationEmailFlag = false) { $forceFlush = APPLICATION_ENV == "production" ? false : true; $cachedSystemData = $this->systemCacheHandler->getCachedSystemData($forceFlush); $settings = $cachedSystemData[CacheHandler::SETTINGS_KEY]; if (array_key_exists(Settings::SYSTEM_EMAIL, $settings)) { $from = $settings[Settings::SYSTEM_EMAIL]; } if (!isset($from)) { throw new \Exception("From email is not set"); } $serverUrl = new ServerUrl(); $serverUrlString = $serverUrl(); $templateParameters = array("request" => $request, "serverUrl" => $serverUrlString); // if tctv mail if ($notificationEmailFlag === false) { $templateName = MailTempates::EXAM_APPROVAL_REQUEST_TEMPLATE; $subject = MailSubjects::EXAM_APPROVAL_REQUEST_SUBJECT; } else { $templateName = MailTempates::NEW_EXAM_NOTIFICATION_TEMPLATE; $subject = MailSubjects::NEW_EXAM_NOTIFICATION_SUBJECT; } $mailArray = array('to' => $to, 'from' => $from, 'templateName' => $templateName, 'templateParameters' => $templateParameters, 'subject' => $subject); $this->notification->notify($mailArray); }
/** * Submit contact us message * * @access public * @param array $data * @param DefaultModule\Form\ContactUsForm $form * @return boolean true if message is sent successfully * @throws \Exception To email is not set */ public function submitMessage($data, $form) { $submissionResult = array(); $forceFlush = APPLICATION_ENV == "production" ? false : true; $cachedSystemData = $this->systemCacheHandler->getCachedSystemData($forceFlush); $settings = $cachedSystemData[CacheHandler::SETTINGS_KEY]; $toArray = array(); if (array_key_exists(Settings::OPERATIONS_EMAIL, $settings) && array_key_exists(Settings::ADMIN_EMAIL, $settings)) { $toArray[] = $settings[Settings::OPERATIONS_EMAIL]; $toArray[] = $settings[Settings::ADMIN_EMAIL]; } if (count($toArray) == 0) { throw new \Exception("To email is not set"); } $mailArray = array('to' => $toArray, 'from' => $data['email'], 'templateName' => MailTempates::CONTACT_US_TEMPLATE, 'templateParameters' => array("data" => $data), 'subject' => MailSubjects::CONTACT_US_SUBJECT); $this->notification->notify($mailArray); $submissionResult[]['message'] = "Your message has been submitted successfully."; $submissionResult['messages'] = $submissionResult; $submissionResult['status'] = true; // clear form $form->setData(array('name' => '', 'subject' => '', 'message' => '', 'email' => '')); return $submissionResult; }
/** * Send mail * * @access private * @param string $userEmail * @param bool $editFlag * @throws \Exception From email is not set * @throws \Exception Admin email is not set * @throws \Exception Operations email is not set */ private function sendMail($userEmail, $editFlag) { $forceFlush = APPLICATION_ENV == "production" ? false : true; $cachedSystemData = $this->systemCacheHandler->getCachedSystemData($forceFlush); $settings = $cachedSystemData[CacheHandler::SETTINGS_KEY]; if (array_key_exists(Settings::SYSTEM_EMAIL, $settings)) { $from = $settings[Settings::SYSTEM_EMAIL]; } if (array_key_exists(Settings::ADMIN_EMAIL, $settings)) { $adminEmail = $settings[Settings::ADMIN_EMAIL]; } if (array_key_exists(Settings::OPERATIONS_EMAIL, $settings)) { $operationsEmail = $settings[Settings::OPERATIONS_EMAIL]; } if (!isset($from)) { throw new \Exception("From email is not set"); } if (!isset($adminEmail)) { throw new \Exception("Admin email is not set"); } if (!isset($operationsEmail)) { throw new \Exception("Operations email is not set"); } $templateParameters = array("email" => $userEmail); if ($editFlag === false) { $templateName = MailTempates::NEW_ORGANIZATION_NOTIFICATION_TEMPLATE; $subject = MailSubjects::NEW_ORGANIZATION_NOTIFICATION_SUBJECT; } else { $templateName = MailTempates::UPDATED_ORGANIZATION_NOTIFICATION_TEMPLATE; $subject = MailSubjects::UPDATED_ORGANIZATION_NOTIFICATION_SUBJECT; } $notificationMailArray = array('to' => $adminEmail, 'from' => $from, 'templateName' => $templateName, 'templateParameters' => $templateParameters, 'subject' => $subject); $this->notification->notify($notificationMailArray); if ($editFlag === false) { $welcomeKitMailArray = array('to' => $operationsEmail, 'from' => $from, 'templateName' => MailTempates::NEW_ORGANIZATION_WELCOME_KIT_TEMPLATE, 'templateParameters' => $templateParameters, 'subject' => MailSubjects::NEW_ORGANIZATION_WELCOME_KIT_SUBJECT); $this->notification->notify($welcomeKitMailArray); } }