Skip to content

Commit

Permalink
Merge pull request mautic#12495 from shinde-rahul/import-custom-email…
Browse files Browse the repository at this point in the history
…-template

Fixing Import custom email template functionality
  • Loading branch information
escopecz authored Sep 26, 2023
2 parents 34a7de0 + 1217759 commit b476261
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/bundles/EmailBundle/Helper/MailHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1415,13 +1415,11 @@ public function setEmail(Email $email, $allowBcc = true, $slots = [], $assetAtta
$this->setPlainText($plainText);
}

$BCcontent = $email->getContent();
$template = $email->getTemplate();
$customHtml = $email->getCustomHtml();
// Process emails created by Mautic v1
if (empty($customHtml) && !empty($BCcontent)) {
$template = $email->getTemplate();
if (empty($customHtml) && $template) {
if (empty($slots)) {
$template = $email->getTemplate();
$slots = $this->factory->getTheme($template)->getSlots('email');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,35 @@ public function testEmailDetailsPageShouldNotHavePendingCount(): void

$this->assertCount(0, $pendingCountQuery);
}

public function testSendEmailForImportCustomEmailTemplate(): void
{
$email = new Email();
$email->setName('Test Email C');
$email->setSubject('Test Email C Subject');
$email->setTemplate('blank');
$email->setEmailType('template');

$contact = new Lead();
$contact->setEmail('[email protected]');

$this->em->persist($email);
$this->em->persist($contact);
$this->em->flush();

// Create the member now.
$payload = [
'action' => 'lead:getEmailTemplate',
'template' => $email->getId(),
];

$this->client->request('GET', '/s/ajax', $payload, [], $this->createAjaxHeaders());
$clientResponse = $this->client->getResponse();
$response = json_decode($clientResponse->getContent(), true);

$this->assertSame(1, $response['success']);
$this->assertNotEmpty($response['subject']);
$this->assertEquals($email->getSubject(), $response['subject']);
$this->assertNotEmpty($response['body']);
}
}

0 comments on commit b476261

Please sign in to comment.