feat: disable mailjet open and click tracking
This commit is contained in:
1 parent
8898320e21
commit
2ef831c5c4
2 files changed
+72
No files matched your search
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Email;
|
||||
|
||||
use App\Email\Mailer;
|
||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* What a mail carries for the transport it goes out over, built through the real template stack.
|
||||
*/
|
||||
class MailerTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* Mailjet would otherwise track opens and rewrite links if the account is set to, which staff
|
||||
* mail - mailings and reminders alike - must not be.
|
||||
*/
|
||||
public function testMailOverMailjetIsNotTracked(): void
|
||||
{
|
||||
$headers = $this->create(Mailer::MAILJET_TRANSPORT)->getHeaders();
|
||||
|
||||
$this->assertSame(Mailer::MAILJET_TRANSPORT, $headers->get('X-Transport')?->getBodyAsString());
|
||||
$this->assertSame('0', $headers->get('X-Mailjet-TrackOpen')?->getBodyAsString());
|
||||
$this->assertSame('0', $headers->get('X-Mailjet-TrackClick')?->getBodyAsString());
|
||||
}
|
||||
|
||||
/**
|
||||
* The webhoster's relay would pass Mailjet headers on to the recipient as noise.
|
||||
*/
|
||||
public function testMailOverTheRelayCarriesNoMailjetHeaders(): void
|
||||
{
|
||||
$headers = $this->create(null)->getHeaders();
|
||||
|
||||
$this->assertFalse($headers->has('X-Transport'));
|
||||
$this->assertFalse($headers->has('X-Mailjet-TrackOpen'));
|
||||
$this->assertFalse($headers->has('X-Mailjet-TrackClick'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Mailer::create() takes the options as createAndSendEmail() has resolved them.
|
||||
*/
|
||||
private function create(?string $transport): TemplatedEmail
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
return self::getContainer()->get(Mailer::class)->create(['feedbacks' => []], [
|
||||
'from' => '[email protected]',
|
||||
'to' => '[email protected]',
|
||||
'subject' => 'Betreff',
|
||||
'subject_parameters' => [],
|
||||
'template' => 'email/reminder_pending_feedback.html.twig',
|
||||
'attachments' => [],
|
||||
'transport' => $transport,
|
||||
'bus_transport' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user