getContainer()->getPermissionsService()->currentUserCanWrite(Entities::NOTIFICATIONS)) { throw new AccessDeniedException('You are not allowed to send test email'); } $result = new CommandResult(); $this->checkMandatoryFields($command); /** @var PHPMailService|SMTPService|MailgunService $mailService */ $mailService = $this->getContainer()->get('infrastructure.mail.service'); /** @var EmailNotificationService $notificationService */ $notificationService = $this->getContainer()->get('application.emailNotification.service'); /** @var PlaceholderService $placeholderService */ $placeholderService = $this->getContainer()->get("application.placeholder.{$command->getField('type')}.service"); $notification = $notificationService->getByNameAndType($command->getField('notificationTemplate'), 'email'); $dummyData = $placeholderService->getPlaceholdersDummyData(); $subject = $placeholderService->applyPlaceholders( $notification->getSubject()->getValue(), $dummyData ); $content = $placeholderService->applyPlaceholders( $notification->getContent()->getValue(), $dummyData ); /** @var SettingsService $bccEmail */ $bccEmail = $this->getContainer()->get('domain.settings.service')->getSetting('notifications','bccEmail'); ($bccEmail !== '') ? $bcc = $bccEmail : $bcc = false; $mailService->send($command->getField('recipientEmail'), $subject, $content, $bcc); $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Test email successfully sent'); return $result; } }