Commit 748cad6b authored by Georgi Mateev's avatar Georgi Mateev
Browse files

[BUGFIX] 1584 Removed unnecessary complex logic from the Newsletter and SendEmail

parent a2711427
......@@ -828,15 +828,16 @@ class MailTemplateService {
* @param boolean $isNewsletter
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
protected function extractValuesForMail(
protected function parseValuesForMail(
$template, RegisterService $registerService, $defaultTemplateContent,
$siteRootId, $isNewsletter
$siteRootId
): void {
/** @var StandaloneView $emailView */
$emailView = $this->objectManager->get(StandaloneView::class);
$emailView->assignMultiple($this->markers);
$emailView->assign('all_fields', $this->getAllMarker($this->markers));
//TODO: make this as the lines below the next block
$overwrittenEmailBody = $this->getOverwrittenEmailBody();
$overwrittenSubject = '';
if ($this->subject !== '' && $this->subject !== NULL) {
......@@ -875,57 +876,27 @@ class MailTemplateService {
// Parse the markers
if ($this->fromName) {
$this->setFromName(
$this->parseMarkers(
$this->fromName,
$emailView
)
);
$this->setFromName($this->parseMarkers($this->fromName, $emailView));
}
if ($this->fromAddress) {
$this->setFromAddress(
$this->parseMarkers(
$this->fromAddress,
$emailView
)
);
$this->setFromAddress($this->parseMarkers($this->fromAddress, $emailView));
}
if ($this->replyToAddress) {
$this->setReplyToAddress(
$this->parseMarkers(
$this->replyToAddress,
$emailView
)
);
$this->setReplyToAddress($this->parseMarkers($this->replyToAddress, $emailView));
}
if ($this->bccAddresses) {
$this->setCcAddresses(
$this->parseMarkers(
$this->ccAddresses,
$emailView
)
);
if ($this->ccAddresses) {
$this->setCcAddresses($this->parseMarkers($this->ccAddresses, $emailView));
}
if ($this->bccAddresses) {
$this->setBccAddresses(
$this->parseMarkers(
$this->bccAddresses,
$emailView
)
);
$this->setBccAddresses($this->parseMarkers($this->bccAddresses, $emailView));
}
if ($this->toAddresses) {
$this->setToAddresses(
$this->parseMarkers(
$this->toAddresses,
$emailView
)
);
$this->setToAddresses($this->parseMarkers($this->toAddresses, $emailView));
}
// reset template source back to default
......@@ -994,12 +965,7 @@ class MailTemplateService {
$this->setToAddresses(\trim($template->getToAddress()));
}
$this->extractValuesForMail($template, $registerService, $defaultTemplateContent, $siteRootId, $isNewsletter);
// Fallback empty recipient address to the default sender address
if (!$this->mailMessage->getTo()) {
$this->mailMessage->setTo($this->defaultFromAddress);
}
$this->parseValuesForMail($template, $registerService, $defaultTemplateContent, $siteRootId);
$mail = $this->addMailToMailQueue(
$this->extensionKey, $this->templateName, $this->getSubjectToSend(), $this->getMailBodyToSend(),
......@@ -1308,7 +1274,7 @@ class MailTemplateService {
*
* @param Template $template
*/
private function loadTemplateValues($template): void {
private function loadTemplateValues(Template $template): void {
$fromName = \trim($template->getFromName());
if ($fromName === '') {
$fromName = $this->fromName;
......@@ -1318,6 +1284,7 @@ class MailTemplateService {
}
$fromMail = $this->getValidFromMail(\trim($template->getFromMail()));
// The setters check if the value is empty or not
$this->setFromAddress($fromMail, $fromName);
$this->setCcAddresses($template->getCc());
$this->setBccAddresses($template->getBcc());
......
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