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

Appearance settings

[Mailer] Fix the possibility to set a From header from MessageListener #31774

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

Merged
merged 1 commit into from
Jun 4, 2019

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented May 31, 2019

Q A
Branch? 4.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #31733
License MIT
Doc PR n/a

@@ -40,14 +37,7 @@ public function __construct(Address $sender, array $recipients)

public static function create(RawMessage $message): self
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if we should keep this method.

@weaverryan
Copy link
Member

weaverryan commented May 31, 2019

@fabpot I'm getting a new error:

An email must have a "From" header

I think it relates to the difference between "Sender" and "From" that I was mentioning (#31733 (comment)) - though I'm far from an expert on this stuff. Should the EnvelopeListener set both sender and from? Or just the from, since the sender is derived from that?

@fabpot
Copy link
Member Author

fabpot commented May 31, 2019

"From" is what you write on the letter, "Sender" is what you write on the envelope. If you don't provide an envelope, we create one for you based on what you wrote on the letter. So, you must always provide a "From" (or register a MessageListener to do it for you -- will be part of the semantic configuration when available of course).

src/Symfony/Component/Mailer/DelayedSmtpEnvelope.php Outdated Show resolved Hide resolved
@nicolas-grekas nicolas-grekas added this to the 4.3 milestone Jun 1, 2019
@fabpot fabpot force-pushed the from-header-from-listener-fix branch from 146f260 to f4254e6 Compare June 1, 2019 08:24

public function __construct(RawMessage $message)
{
if (!$message instanceof Message) {
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be better to change the type-hint instead? If we want to support any other message in the future we can still change the type then.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so. I've done it that way to get a "better" error message.

Copy link
Member

Choose a reason for hiding this comment

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

But it means that the user will only get an error at runtime if they didn't discover before that Message instances are required here. With a proper type hint they can be warned before.

Copy link
Member Author

Choose a reason for hiding this comment

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

How would they be warned before? I suppose you're thinking about static analysis. Not sure what to do.

Copy link
Member Author

Choose a reason for hiding this comment

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

In any case, that's independent from this PR as I'm doing the same at several other places (and this code is copy/pasted from SmtpEnvelope).

Copy link
Member Author

Choose a reason for hiding this comment

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

@fabpot fabpot merged commit f4254e6 into symfony:4.3 Jun 4, 2019
fabpot added a commit that referenced this pull request Jun 4, 2019
…sageListener (fabpot)

This PR was merged into the 4.3 branch.

Discussion
----------

[Mailer] Fix the possibility to set a From header from MessageListener

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #31733
| License       | MIT
| Doc PR        | n/a

<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against branch 4.4.
 - Legacy code removals go to the master branch.
-->

Commits
-------

f4254e6 [Mailer] fixed the possibility to set a From header from MessageListener
@fabpot fabpot mentioned this pull request Jun 4, 2019
fabpot added a commit that referenced this pull request Jun 4, 2019
This PR was merged into the 4.3 branch.

Discussion
----------

Change type hints

| Q             | A
| ------------- | ---
| Branch?       | 4.3 for features / 3.4, 4.2 or 4.3 for bug fixes <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

see #31774 (comment)

<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against branch 4.4.
 - Legacy code removals go to the master branch.
-->

Commits
-------

d56ae06 changed type hints
@fabpot fabpot mentioned this pull request Jun 6, 2019
@fabpot fabpot deleted the from-header-from-listener-fix branch July 18, 2019 20:17
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.

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