Skip to content

Commit 109b07a

Browse files
committed
EmailBuilder
1 parent 492e1d0 commit 109b07a

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

config/parameters.yml.dist

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ parameters:
3636
app.mailer_from: '%%env(MAILER_FROM)%%'
3737
env(MAILER_FROM): '[email protected]'
3838
app.mailer_dsn: '%%env(MAILER_DSN)%%'
39-
env(MAILER_DSN): 'null://null'
39+
env(MAILER_DSN): 'null://null' # set local_domain on transport
4040
app.confirmation_url: '%%env(CONFIRMATION_URL)%%'
4141
env(CONFIRMATION_URL): 'https://example.com/subscriber/confirm/'
4242
app.subscription_confirmation_url: '%%env(SUBSCRIPTION_CONFIRMATION_URL)%%'
@@ -101,6 +101,12 @@ parameters:
101101
env(USE_MANUAL_TEXT_PART): 0
102102
messaging.blacklist_grace_time: '%%env(MESSAGING_BLACKLIST_GRACE_TIME)%%'
103103
env(MESSAGING_BLACKLIST_GRACE_TIME):
104+
messaging.google_sender_id: '%%env(GOOGLE_SENDERID)%%'
105+
env(GOOGLE_SENDERID): ''
106+
messaging.use_amazon_ses: '%%env(USE_AMAZONSES)%%'
107+
env(USE_AMAZONSES): 0
108+
messaging.embed_external_images: '%%env(EMBEDEXTERNALIMAGES)%%'
109+
env(EMBEDEXTERNALIMAGES): 0
104110

105111
phplist.upload_images_dir: '%%env(PHPLIST_UPLOADIMAGES_DIR)%%'
106112
env(PHPLIST_UPLOADIMAGES_DIR): 'images'
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpList\Core\Domain\Messaging\Service\Builder;
6+
7+
use Symfony\Component\Mime\Email;
8+
9+
class EmailBuilder
10+
{
11+
public function __construct(
12+
private readonly string $googleSenderId,
13+
private readonly bool $useAmazonSes,
14+
private readonly bool $usePrecedenceHeader,
15+
) {
16+
}
17+
18+
public function buildPhplistEmail(
19+
string $messageId,
20+
string $destinationEmail,
21+
bool $inBlast = true,
22+
): Email {
23+
$email = (new Email());
24+
25+
$email->getHeaders()->addTextHeader('X-MessageID', $messageId);
26+
$email->getHeaders()->addTextHeader('X-ListMember', $destinationEmail);
27+
if ($this->googleSenderId !== '') {
28+
$email->getHeaders()->addTextHeader('Feedback-ID', sprintf('%s:%s', $messageId, $this->googleSenderId));
29+
}
30+
31+
if (!$this->useAmazonSes && $this->usePrecedenceHeader) {
32+
$email->getHeaders()->addTextHeader('Precedence', 'bulk');
33+
}
34+
35+
if ($inBlast) {
36+
$email->getHeaders()->addTextHeader('X-Blast', '1');
37+
}
38+
39+
return $email;
40+
}
41+
}

0 commit comments

Comments
 (0)