Commit f0a07f83 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Refactoring mail model

parent 918ba1bc
......@@ -28,6 +28,7 @@ namespace SGalinski\SgMail\Command;
use SGalinski\SgMail\Domain\Model\Mail;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\CommandController;
/**
......@@ -59,7 +60,10 @@ class SendMailCommandController extends CommandController {
$fromAddress = $mailToSend->getFromAddress();
$toAddress = $mailToSend->getToAddress();
$ccAddresses = GeneralUtility::trimExplode(',', $mailToSend->getCcAddresses());
$bccAddresses = GeneralUtility::trimExplode(',', $mailToSend->getBccAddresses());
$mailSubject = $mailToSend->getMailSubject();
$fromName = $mailToSend->getFromName();
$mailBody = $mailToSend->getMailBody();
$mailToSend->setSent(TRUE);
......@@ -72,7 +76,11 @@ class SendMailCommandController extends CommandController {
$mailMessage->setFrom($fromAddress);
$mailMessage->setTo($toAddress);
$mailMessage->setSubject($mailSubject);
$mailMessage->setCc($ccAddresses);
$mailMessage->setBcc($bccAddresses);
$mailMessage->setFrom($fromName);
$mailMessage->setBody($mailBody, 'text/html');
$mailMessage->send();
}
......
......@@ -69,6 +69,21 @@ class Mail extends AbstractEntity {
*/
protected $priority = 0;
/**
* @var string
*/
protected $bccAddresses = '';
/**
* @var string
*/
protected $ccAddresses = '';
/**
* @var string
*/
protected $fromName = '';
/**
* @return string
*/
......@@ -158,4 +173,46 @@ class Mail extends AbstractEntity {
public function setPriority($priority) {
$this->priority = (int) $priority;
}
/**
* @return string
*/
public function getBccAddresses() {
return $this->bccAddresses;
}
/**
* @param string $bccAddresses
*/
public function setBccAddresses($bccAddresses) {
$this->bccAddresses = $bccAddresses;
}
/**
* @return string
*/
public function getCcAddresses() {
return $this->ccAddresses;
}
/**
* @param string $ccAddresses
*/
public function setCcAddresses($ccAddresses) {
$this->ccAddresses = $ccAddresses;
}
/**
* @return string
*/
public function getFromName() {
return $this->fromName;
}
/**
* @param string $fromName
*/
public function setFromName($fromName) {
$this->fromName = $fromName;
}
}
......@@ -257,6 +257,8 @@ class MailTemplateService {
$mail->setMailSubject($this->subject);
$mail->setMailBody($emailBody);
$mail->setPriority($priority);
$mail->setBccAddresses(implode(',', $this->bccAddresses));
$mail->setCcAddresses(implode(',', $this->ccAddresses));
$mailRepository = $objectManager->get(MailRepository::class);
$mailRepository->add($mail);
......@@ -384,5 +386,4 @@ class MailTemplateService {
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