Commit 87f375ee authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Adding return value to send mail method, to determine if it was successfull

parent 4fa8ae4e
......@@ -274,10 +274,14 @@ class MailController extends ActionController {
$mailTemplateService->setSubject($this->settings['mail']['test']['subject']);
$mailTemplateService->setTemplateName($selectedTemplateKey);
$mailTemplateService->setExtensionKey($selectedExtensionKey);
$mailTemplateService->sendEmail();
$message = LocalizationUtility::translate('backend.success_mail', 'sg_mail');
$this->addFlashMessage($message, '', FlashMessage::OK);
if ($mailTemplateService->sendEmail()) {
$message = LocalizationUtility::translate('backend.success_mail', 'sg_mail');
$this->addFlashMessage($message, '', FlashMessage::OK);
} else {
$message = LocalizationUtility::translate('backend.failure_mail', 'sg_mail');
$this->addFlashMessage($message, '', FlashMessage::ERROR);
}
$arguments = $this->request->getArguments();
$this->redirect('index', NULL, NULL, $arguments);
......
......@@ -188,6 +188,8 @@ class MailTemplateService {
/**
* Send the Email
*
* @return boolean email was sent or added to mail queue successfully?
*/
public function sendEmail() {
......@@ -199,6 +201,11 @@ class MailTemplateService {
$template = $this->templateRepository->findTemplate(
$this->extensionKey, $this->templateName, $this->language
)->getFirst();
if ($template === NULL) {
return FALSE;
}
$emailView->setTemplateSource($template->getContent());
$emailView->assignMultiple($this->markers);
$emailBody = $emailView->render();
......@@ -214,6 +221,8 @@ class MailTemplateService {
} else {
$this->addMailToMailQueue($emailBody);
}
return TRUE;
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment