Skip to content
Snippets Groups Projects
Commit 2b96a8d4 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Add attachment support for mail api

parent 42aacb6e
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,8 @@ use SGalinski\SgMail\Domain\Model\Mail;
use SGalinski\SgMail\Domain\Model\Template;
use SGalinski\SgMail\Domain\Repository\MailRepository;
use SGalinski\SgMail\Domain\Repository\TemplateRepository;
use Swift_Attachment;
use Swift_OutputByteStream;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
......@@ -129,6 +131,11 @@ class MailTemplateService {
*/
protected $objectManager;
/**
* @var array
*/
private $attachments = [];
/**
* MailTemplateService constructor.
*/
......@@ -442,4 +449,19 @@ class MailTemplateService {
$this->priority = $priority;
return $this;
}
/**
* @param Swift_OutputByteStream $data
* @param string $path
* @param string $contentType
* @return MailTemplateService
*/
public function addAttachment($data, $filename, $contentType) {
$attachment = Swift_Attachment::newInstance()
->setFilename($filename)
->setContentType($contentType)
->setBody($data);
$this->mailMessage->attach($attachment);
return $this;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment