Skip to content

Allow 'Name <email@address.com>' pattern in framework.mailer.envelop.sender config #36289

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

Closed
wants to merge 1 commit into from

Conversation

maidmaid
Copy link
Contributor

@maidmaid maidmaid commented Mar 31, 2020

Q A
Branch? 5.0
Bug fix? no
New feature? yes
Deprecations? no
Tickets #33091
License MIT
Doc PR /
# config/packages/mailer.yaml
framework:
    mailer:
        dsn: '%env(MAILER_DSN)%'
        envelope:
-            sender: 'email@address.com'
+            sender: 'Name <email@address.com>'

@maidmaid maidmaid changed the title Allow 'Name <email@address.com>' pattern in framework.mailer.envelop.… Allow 'Name <email@address.com>' pattern in framework.mailer.envelop.sender config Mar 31, 2020
@fabpot
Copy link
Member

fabpot commented Mar 31, 2020

AFAIR, a Sender cannot have a name, so I would not allow it to strip it afterwards.

@maidmaid
Copy link
Contributor Author

With gmail, mails are sent with a sender name :
image

@fabpot
Copy link
Member

fabpot commented Mar 31, 2020

Here, you have a From header, not a Sender one.

@fabpot
Copy link
Member

fabpot commented Mar 31, 2020

I'm closing as Sender is NOT the same as a From header. It overrides it.

@fabpot fabpot closed this Mar 31, 2020
@maidmaid
Copy link
Contributor Author

So, how can I send emails with something like My App <no-reply@my-app.com> ?

@fabpot
Copy link
Member

fabpot commented Mar 31, 2020

You need to use a From header. The Sender of the envelope is a way to override the From header in the dev env for instance (that way, you still have the email without any modification).

@maidmaid
Copy link
Contributor Author

We should be able to set globally the From header like the Sender one. I could work on it if you agree.

@xabbuh xabbuh added the Mailer label Mar 31, 2020
@maidmaid
Copy link
Contributor Author

maidmaid commented Mar 31, 2020

Actually, there is no Sender header used here. The sender of the envelope is only used in the From header.

$this->doMailFromCommand($envelope->getSender()->getAddress());

I feel like the framework.mailer.envelope.sender is misnamed and should be callled framework.mailer.envelope.from because it acts exactly as such.

If I deprecate the sender config in favour of from, we could re-open this PR.

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