/** * @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); }
public function testSetsXMailerHeader() { $mail = new Message(); $this->expectedMail = $mail; $mailer = 'test/mailer'; $this->target->setMailer($mailer); $this->target->send($mail); $headers = $mail->getHeaders(); $this->assertTrue($headers->has('X-Mailer')); $this->assertEquals("X-Mailer: {$mailer}", $headers->get('X-Mailer')->toString()); }
/** * 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); }
/** * 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); }
/** * Send Carbon Copy to the User */ protected function sendCarbonCopyToCandidate() { if ($this->application->getAttributes()->getSendCarbonCopy()) { $this->mailService->send('Applications/CarbonCopy', ['application' => $this->application]); } }