Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
fc02a7f
chore: require symfony/mailer. change compatibility to neos >= 8.x
samsauter Apr 16, 2024
b9fcc56
chore: add factories for to symfony mailer. re-add interception funct…
samsauter Apr 16, 2024
58062b3
chore: WIP add functionality to render e-mail html from nodes.
samsauter Apr 17, 2024
dd4b9da
fix: remove obsolete fusion include path.
samsauter Apr 17, 2024
4bef2cb
chore: add functionality to get node's uri.
samsauter Apr 25, 2024
1337403
chore: require guzzlehttp/guzzle.
samsauter Apr 26, 2024
4ab7b83
chore: use guzzle client for requests. add logging.
samsauter Apr 26, 2024
717d48e
chore: add functionality to send node based e-mail template with neos…
samsauter Apr 26, 2024
092e986
chore: fix subject for intercepted e-mails.
samsauter Apr 29, 2024
496477b
chore: refactor `ContentRepositoryService` after `ContentRepositoryId…
samsauter Jul 16, 2024
dcb2b84
chore: fix nodeId references for neos 9 beta 10.
samsauter Jul 16, 2024
f4746b6
chore: `getContentGraph` not need the workspace name as an argument.
samsauter Jul 24, 2024
2541a4b
chore: changes for neos 9 beta-11. rewrite `uriForNode()`. See https:…
samsauter Aug 19, 2024
c3aa570
docs: update readme for new package version with symfony mailer.
samsauter Sep 16, 2024
6d49211
docs: fix release notes.
samsauter Sep 16, 2024
bae1983
chore: Neos Beta14: replace `getWorkspaceFinder()` with `findWorkspa…
samsauter Oct 28, 2024
933bdf4
chore: getNodeById() now fetches node from subgraph in correct dimension
samsauter Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 0 additions & 85 deletions Classes/Aspect/DebuggingAspect.php

This file was deleted.

24 changes: 24 additions & 0 deletions Classes/Command/MailerCommandController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
namespace FormatD\Mailer\Command;

use FormatD\Mailer\Service\AbstractMailerService;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cli\CommandController;

/**
* @Flow\Scope("singleton")
*/
class MailerCommandController extends CommandController
{
#[Flow\Inject]
protected AbstractMailerService $abstractMailerService;

/**
* @param string $to
* ./flow mailer:sendTest --to someone@somewhere.com
*/
public function sendTestCommand($to)
{
$this->abstractMailerService->sendTest($to);
}
}
51 changes: 51 additions & 0 deletions Classes/DataSource/EmailReferenceDataSource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
namespace FormatD\Mailer\DataSource;

use Neos\Eel\FlowQuery\FlowQuery;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Service\DataSource\AbstractDataSource;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface;

class EmailReferenceDataSource extends AbstractDataSource
{

/**
* @var string
*/
protected static $identifier = 'formatd-mailer-email-reference';

/**
* @var string
*/
protected static $icon = 'icon-envelope';

#[Flow\Inject]
protected NodeLabelGeneratorInterface $nodeLabelGenerator;

/**
* @param Node|null $node
* @param array $arguments
* @return array|mixed
* @throws \Neos\Eel\Exception
*/
public function getData(Node $node = null, array $arguments = [])
{
$q = new FlowQuery([$node]);
$emailNodes = $q
->parents('[instanceof FormatD.DesignSystem:Site]')
->find('[instanceof FormatD.Mailer:Document.Email]')
->get();

$data = [];
foreach ($emailNodes as $emailNode) {
$data[] = [
'label' => $this->nodeLabelGenerator->getLabel($emailNode),
'value' => $emailNode->aggregateId,
'icon' => static::$icon
];
}

return $data;
}
}
79 changes: 79 additions & 0 deletions Classes/Factories/MailFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

declare(strict_types=1);

namespace FormatD\Mailer\Factories;

use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;

class MailFactory
{
/**
* @param string $subject
* @param Address[]|Address|string $to
* @param Address|string $from
* @param string|null $text
* @param string|null $html
* @param Address[]|Address|string|null $replyTo
* @param Address[]|Address|string|null $cc
* @param Address[]|Address|string|null $bcc
* @return Email
*/
public function createMail(
string $subject,
array|Address|string $to,
Address|string $from,
string $text = null,
string $html = null,
array|Address|string $replyTo = null,
array|Address|string $cc = null,
array|Address|string $bcc = null
): Email {
$mail = new Email();

$mail
->from($from)
->subject($subject);

if (is_array($to)) {
$mail->to(...$to);
} else {
$mail->to($to);
}

if ($replyTo) {
if (is_array($replyTo)) {
$mail->replyTo(...$replyTo);
} else {
$mail->replyTo($replyTo);
}
}

if ($cc) {
if (is_array($cc)) {
$mail->cc(...$cc);
} else {
$mail->cc($cc);
}
}

if ($bcc) {
if (is_array($bcc)) {
$mail->bcc(...$bcc);
} else {
$mail->bcc($bcc);
}
}

if ($text) {
$mail->text($text);
}

if ($html) {
$mail->html($html);
}

return $mail;
}
}
35 changes: 35 additions & 0 deletions Classes/Factories/MailerFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace FormatD\Mailer\Factories;

use Neos\Flow\Annotations as Flow;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mailer\Transport;

class MailerFactory
{

#[Flow\InjectConfiguration(package: "FormatD.Mailer", path: "")]
protected array $configuration = [];

/**
* @param string|string[]|null $dsn
*/
public function createMailer(string|array $dsn = null): MailerInterface
{
$dsn = $dsn ?: $this->configuration['dsn'] ?? null;

if (is_array($dsn)) {
$transport = Transport::fromDsns($dsn);
} elseif (is_string($dsn)) {
$transport = Transport::fromDsn($dsn);
} else {
throw new \InvalidArgumentException("Mailer needs a transport dsn configuration");
}

return new Mailer($transport);
}
}
Loading