Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Mailer][Mime] add support for external template engine to mail #60062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.3
Choose a base branch
Loading
from

Conversation

antonycohen
Copy link

@antonycohen antonycohen commented Mar 27, 2025

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

There are several mailer services (mailjet, brevo, mailgun,etc..) that allow to design templates directly using their platform.
Currently the mailer component cannot manage this, it's mandatory to manage the rendering before the "send" function

This implementation allow to support that kind of flow.

If this is accepted, I will manage to update existing mailing transport to also support ExternalTemplatedEmail.

here is an exemple of usage

$email = (new ExternalTemplatedEmail())
    ->from('from@example.com')
    ->to('to@dpaas.fr')
    ->templateId('my_template_id')
    ->context([
        'first_name' => 'My FirstName',
    ]);

$this->mailer->send($email);

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.3 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@antonycohen antonycohen force-pushed the mailer-external-template-mail branch from 07dc963 to 16f0c43 Compare March 27, 2025 11:33
@94noni
Copy link
Contributor

94noni commented Mar 28, 2025

I like the idea, would definitely help imho

@carsonbot carsonbot changed the title [Mailer] add support for external template engine to mail [Mailer][Mime] add support for external template engine to mail Mar 30, 2025
@antonycohen antonycohen force-pushed the mailer-external-template-mail branch from 779c0cd to 1c9315c Compare March 30, 2025 09:53
@antonycohen antonycohen requested a review from OskarStark April 3, 2025 09:45
Comment on lines +6 to +7
* Add `ExternalTemplatedEmail`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Add `ExternalTemplatedEmail`
* Add `ExternalTemplatedEmail`


Message::ensureValidity();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* @return $this
*/

use PHPUnit\Framework\TestCase;
use Symfony\Component\Mime\ExternalTemplatedEmail;

class ExternalTemplatedEmailTest extends TestCase
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class ExternalTemplatedEmailTest extends TestCase
final class ExternalTemplatedEmailTest extends TestCase


public function testInvalidTemplateIdExternalTemplatedEmail()
{
$this->expectException(\LogicException::class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please assert the LogicException from the Mailer here, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.