Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

[Mailer] Addrecipient_fetcher option that allows fetching global recipients from a service#62165

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
nxtpge wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromnxtpge:mailer-recipient-fetcher

Conversation

@nxtpge
Copy link

@nxtpgenxtpge commentedOct 26, 2025
edited
Loading

QA
Branch?7.4
Bug fix?no
New feature?yes
Deprecations?no
Issues
LicenseMIT

Until now, theMailer component provided two ways to configure recipients globally:

  • amailer.envelope.recipients option for static ones,
  • aMessageEvent event for dynamic ones.

As a new developer joining an existing Symfony project and assigned to work with theMailer component, your first action would be to look at theconfig/packages/mailer.yaml file.

However, if the recipients were configured through anEventListener, you would need more time to be aware of its existence.

Today, in order to improve the developer experience, I propose to add amailer.envelope.recipient_fetcher option that allows fetching global recipients from a service, and therefore from external sources (database, LDAP, etc.).

Example

config/packages/mailer.yaml
framework:mailer:envelope:recipients:                -redirected@example.orgrecipient_fetcher:App\Mailer\AdminRecipientFetcher# Overwrites the "recipients" option's addresses
src/Mailer/AdminRecipientFetcher.php
<?phpnamespaceApp\Mailer;useApp\Entity\User;useApp\Repository\UserRepository;useSymfony\Component\Mailer\Envelope\RecipientFetcherInterface;useSymfony\Component\Mime\Address;class AdminRecipientFetcherimplements RecipientFetcherInterface{publicfunction__construct(privateUserRepository$userRepository,   ) {   }/**    * @return array<Address|string>    */publicfunctionfetchRecipients():array   {$admins =$this->userRepository->findAdmins();return$admins           ->map(staticfn (User$user):Address =>newAddress($user->getEmail()))           ->toArray();   }}

Acknowledgements

  • @Spomky who inspired me with the idea of a "fetcher" (pull request),
  • @weaverryan who helped me to understand the meaning of the "autowire" and "autoconfigure" options (SymfonyCasts course),
  • api-platform/core andlexik/LexikJWTAuthenticationBundle which taught me how to check in the configuration if a class implements an interface,
  • theSymfony documentation which taught me how the validation rules worked in the configuration.

@carsonbot
Copy link

Hey!

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

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.4 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

@nxtpgenxtpgeforce-pushed themailer-recipient-fetcher branch fromef04c78 to7213ed3CompareOctober 26, 2025 20:00
@nxtpge
Copy link
Author

For the failing checks, I do not understand why theRecipientFetcherInterface interface cannot be found while the problem does not occur in the other ones.

Copy link
Member

@GromNaNGromNaN left a comment

Choose a reason for hiding this comment

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

For the failing checks, I do not understand why theRecipientFetcherInterface interface cannot be found while the problem does not occur in the other ones.

The failing jobs run the tests after installing the dependencies ofsrc/Symfmony/Bundle/FrameworkBundle/composer.json with lowest and highest versions constraint. Currently the new classes doesn't exist insymfony/mailer in any version (v6.4.0 and8.0.x-dev 46faf03 are tested).

@nxtpgenxtpgeforce-pushed themailer-recipient-fetcher branch from7213ed3 toac6a3c9CompareOctober 27, 2025 05:58
@nxtpge
Copy link
Author

The failing jobs run the tests after installing the dependencies ofsrc/Symfmony/Bundle/FrameworkBundle/composer.json with lowest and highest versions constraint. Currently the new classes doesn't exist insymfony/mailer in any version (v6.4.0 and8.0.x-dev 46faf03 are tested).

Thank you@GromNaN for giving me the explanation and the hints I needed to make the checks pass.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@GromNaNGromNaNGromNaN left review comments

Assignees

No one assigned

Projects

None yet

Milestone

7.4

Development

Successfully merging this pull request may close these issues.

3 participants

@nxtpge@carsonbot@GromNaN

[8]ページ先頭

©2009-2025 Movatter.jp