Пример #1
0
 public function testAddsDefaultInitializersWhenConstructed()
 {
     $config = new MailServiceConfig(array('invokables' => array('testTranslatorMessage' => '\\Core\\Mail\\TranslatorAwareMessage', 'testMessageWithInit' => '\\CoreTest\\Mail\\MailService\\MessageWithInitMethod')));
     $translator = $this->getMockBuilder('\\Zend\\I18n\\Translator\\Translator')->disableOriginalConstructor()->getMock();
     $services = $this->getMockBuilder('\\Zend\\ServiceManager\\ServiceManager')->disableOriginalConstructor()->getMock();
     $services->expects($this->once())->method('get')->with('translator')->willReturn($translator);
     $target = new MailService($config);
     $target->setServiceLocator($services);
     $mail = $target->get('testTranslatorMessage');
     $this->assertSame($translator, $mail->getTranslator());
     $this->assertTrue($mail->isTranslatorEnabled());
     $mail = $target->get('testMessageWithInit');
     $this->assertTrue($mail->initCalled, 'Init() initializer did not work!');
 }
Пример #2
0
 /**
  * @param AuthEvent $e
  *
  * @return mixed
  */
 public function __invoke(AuthEvent $e)
 {
     $siteName = $this->coreOptions->getSiteName();
     $user = $e->getUser();
     $userEmail = $user->info->email;
     $userName = $user->info->displayName;
     $resetLink = $e->getResetLink();
     $fromEmail = $this->options->getFromEmail();
     $fromName = $this->options->getFromName();
     $mail = $this->mailService->get('htmltemplate');
     $mail->user = $user;
     $mail->resetlink = $resetLink;
     $mail->setTemplate('mail/forgotPassword');
     $mail->setSubject(sprintf('a new password was requestet for %s', $siteName));
     $mail->setTo($userEmail);
     $mail->setFrom($fromEmail, $fromName);
     return $this->mailService->send($mail);
 }
 protected function sendRecruiterMails()
 {
     /* @var Settings $adminSettings */
     $job = $this->application->getJob();
     $org = $job->getOrganization()->getParent(true);
     $workflow = $org->getWorkflowSettings();
     $admin = $org->getUser();
     $adminSettings = $admin->getSettings('Applications');
     $mailBcc = $adminSettings->getMailBCC();
     if ($workflow->getAcceptApplicationByDepartmentManager()) {
         /* Send mail to department manager, if there is at least one. */
         $managers = $org->getEmployeesByRole(EmployeeInterface::ROLE_DEPARTMENT_MANAGER);
         if (count($managers)) {
             foreach ($managers as $employee) {
                 /* @var EmployeeInterface $employee */
                 $this->mailService->send('Applications/NewApplication', ['job' => $job, 'user' => $employee->getUser(), 'bcc' => $adminSettings->getMailBCC() ? [$admin] : null]);
             }
             return;
         }
     }
     $recruiter = $job->getUser();
     /* @var \Applications\Entity\Settings $settings */
     $settings = $recruiter->getSettings('Applications');
     if ($settings->getMailAccess()) {
         $this->mailService->send('Applications/NewApplication', ['job' => $this->application->getJob(), 'user' => $recruiter, 'bcc' => $adminSettings->getMailBCC() ? [$admin] : null]);
     }
     if ($settings->getAutoConfirmMail()) {
         $ackBody = $settings->getMailConfirmationText();
         if (empty($ackBody)) {
             $ackBody = $settings->getMailConfirmationText();
         }
         if (!empty($ackBody)) {
             /* confirmation mail to the applicant */
             $ackMail = $this->mailService->get('Applications/Confirmation', ['application' => $this->application, 'body' => $ackBody, 'bcc' => $adminSettings->getMailBCC() ? [$admin] : null]);
             // Must be called after initializers in creation
             $ackMail->setSubject('Application confirmation');
             $ackMail->setFrom($recruiter->getInfo()->getEmail(), $recruiter->getInfo()->getDisplayName(false));
             $this->mailService->send($ackMail);
             $this->application->changeStatus(StatusInterface::CONFIRMED, sprintf('Mail was sent to %s', $this->application->getContact()->getEmail()));
         }
     }
 }
Пример #4
0
 /**
  * Sends a job event related mail
  *
  * @param Job    $job
  * @param string $template
  * @param string $subject
  * @param bool   $adminMail if true, the mail is send to the administrator instead of to the user.
  */
 protected function sendMail(Job $job, $template, $subject, $adminMail = false)
 {
     $mail = $this->mailer->get('htmltemplate');
     $mail->setTemplate($template)->setSubject($subject)->setVariables(array('job' => $job, 'siteName' => $this->options['siteName']));
     if ($adminMail) {
         $mail->setTo($this->options['adminEmail']);
     } else {
         $user = $job->getUser();
         $userInfo = $user->getInfo();
         $userEmail = $userInfo->getEmail();
         $userName = $userInfo->getDisplayName(false);
         $mail->setTo($userEmail, $userName);
     }
     $this->mailer->send($mail);
 }
Пример #5
0
 /**
  * Sends the Notification Mail.
  *
  * @param ApplicationEvent $event
  */
 public function sendMail(ApplicationEvent $event)
 {
     if (!$event->isPostRequest()) {
         return;
     }
     $this->application = $event->getApplicationEntity();
     $status = $event->getStatus();
     $user = $event->getUser();
     $post = $event->getPostData();
     $settings = $user->getSettings('Applications');
     $recipient = $this->getRecipient($this->application, $status);
     /* @var \Applications\Mail\StatusChange $mail */
     $mail = $this->mailService->get('Applications/StatusChange');
     $mail->setSubject($post['mailSubject']);
     $mail->setBody($post['mailText']);
     $mail->setTo($recipient);
     if ($from = $this->application->getJob()->getContactEmail()) {
         $mail->setFrom($from, $this->application->getJob()->getCompany());
     }
     if ($settings->mailBCC) {
         $mail->addBcc($user->getInfo()->getEmail(), $user->getInfo()->getDisplayName());
     }
     $job = $this->application->getJob();
     $jobUser = $job->getUser();
     if ($jobUser->getId() != $user->getId()) {
         $jobUserSettings = $jobUser->getSettings('Applications');
         if ($jobUserSettings->getMailBCC()) {
             $mail->addBcc($jobUser->getInfo()->getEmail(), $jobUser->getInfo()->getDisplayName(false));
         }
     }
     $org = $job->getOrganization()->getParent(true);
     $orgUser = $org->getUser();
     if ($orgUser->getId() != $user->getId() && $orgUser->getId() != $jobUser->getId()) {
         $orgUserSettings = $orgUser->getSettings('Applications');
         if ($orgUserSettings->getMailBCC()) {
             $mail->addBcc($orgUser->getInfo()->getEmail(), $orgUser->getInfo()->getDisplayName(false));
         }
     }
     $this->mailService->send($mail);
     $historyText = sprintf($this->translator->translate('Mail was sent to %s'), key($recipient) ?: $recipient[0]);
     $this->application->changeStatus($status, $historyText);
     $event->setNotification($historyText);
 }