Commit 3ee3a60b authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Fixing a bug with multiple to addresses

parent d76d4595
......@@ -369,9 +369,9 @@ class MailTemplateService {
);
if ($this->ignoreMailQueue && !$isTemplateBlacklisted) {
$this->mailMessage->setBody($emailBody, 'text/html');
$plaintextService = GeneralUtility::makeInstance(PlaintextService::class);
$plainTextBody = $plaintextService->makePlain($emailBody);
$this->mailMessage->addPart($plainTextBody, 'text/plain');
$plaintextService = GeneralUtility::makeInstance(PlaintextService::class);
$plainTextBody = $plaintextService->makePlain($emailBody);
$this->mailMessage->addPart($plainTextBody, 'text/plain');
$this->mailMessage->send();
$dateTime = new DateTime();
$currentTimestamp = $dateTime->getTimestamp();
......@@ -463,7 +463,12 @@ class MailTemplateService {
$plaintextService = GeneralUtility::makeInstance(PlaintextService::class);
$plaintextBody = $plaintextService->makePlain($mailToSend->getMailBody());
$this->mailMessage->addPart($plaintextBody, 'text/plain');
$this->mailMessage->setTo(trim($mailToSend->getToAddress()));
$toAddresses = trim($mailToSend->getToAddress());
$addressesArray = GeneralUtility::trimExplode(',', $toAddresses, TRUE);
if (\count($addressesArray) > 1) {
$toAddresses = $addressesArray;
}
$this->mailMessage->setTo($toAddresses);
$this->mailMessage->setFrom($mailToSend->getFromAddress(), $mailToSend->getFromName());
$this->mailMessage->setSubject($mailToSend->getMailSubject());
......@@ -491,9 +496,9 @@ class MailTemplateService {
}
}
$dateTime = new DateTime();
if ((int)$mailToSend->getSendingTime() === 0) {
$mailToSend->setSendingTime($dateTime->getTimestamp());
}
if ((int) $mailToSend->getSendingTime() === 0) {
$mailToSend->setSendingTime($dateTime->getTimestamp());
}
$mailToSend->setLastSendingTime($dateTime->getTimestamp());
$this->mailMessage->send();
$mailRepository->update($mailToSend);
......@@ -505,9 +510,14 @@ class MailTemplateService {
* @return MailTemplateService
*/
public function setToAddresses($toAddresses) {
$toAddresses = preg_replace('~\x{00a0}~siu', ' ', $toAddresses);
$this->toAddresses = trim($toAddresses);
$this->mailMessage->setTo(trim($toAddresses));
$toAddresses = trim(preg_replace('~\x{00a0}~siu', ' ', $toAddresses));
$this->toAddresses = $toAddresses;
$addressesArray = GeneralUtility::trimExplode(',', $toAddresses, TRUE);
if (\count($addressesArray) > 1) {
$toAddresses = $addressesArray;
}
$this->mailMessage->setTo($toAddresses);
return $this;
}
......
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