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
Add support for headers in native mailer #304
Add support for headers in native mailer #304
Conversation
hello @anthonybocci. Your code is not valid. Could you fix it? (It generates a fatal error, see the CI) |
Hello @lyrixx. I didn't see the errors on the page, sorry. I'll fix it. For now the XSD seems not to be valid, my complex type is not accepted. |
There is this error too:
@fabpot Symfony 2.8 is not maintained anymore. I think we could drop support for it. WDYT ? |
I would indeed drop 2.8 support. |
See #306 for the drop |
Thank you @lyrixx for pointing this out, I'll try to have a look this week. |
Hi. I dropped support for SF <3.4. Could you rebase your PR? Thanks |
The native mailer is able to have additional headers, but it wasn't possible to give it any headers in the configuration. Swift mailer may have a content_type key but not native mailer. A new "headers" key is now allowed in the handler configuration, so a list of headers may be given to the handler. Only native mailer supports it. Related to symfony#272
7c344c7
to
7ecbc9e
Compare
I have rebased this PR for you |
The XML is still invalid.
|
Hi, the error is in fact |
fd6db6f
to
b64cb29
Compare
@anthonybocci I finished the PR for you. I pushed in your branch, so if you need to change something, be careful. I have one little question: did you test your work in a real application? I'm asking because of this change if (!empty($handler['headers'])) {
- $definition->addMethodCall('addHeader', $handler['headers']);
+ $definition->addMethodCall('addHeader', [$handler['headers']]);
} I did not test in a real application, but this is how |
Thank you @lyrixx, I was far from the result. |
If you can test it, it would be very nice. Thanks. |
For sure, I will test it this evening. |
@lyrixx I just tested. It is working if I use the following form:
But it's not working when I use the following form:
In the second case only the value is added to the content, not the key. In my commits I tried to implement the first case because it allows to use any chars, and I was not sure if every char was allowed in a YAML key. |
It's weird because according to the test cast it should be ok. I'll look at it in a real app tomorrow. Thanks for your feedbacks |
If it helps, here is the demonstration of what I encounter when I test:
monolog:
handlers:
main:
type: fingers_crossed
action_level: debug
handler: nested
excluded_http_codes: [403, 404]
max_files: 10
deduplicated:
type: deduplication
handler: mail
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
handler: deduplicated
mail:
type: native_mailer
from_email: 'logger@email.com'
to_email: ['dev@email.com']
subject: 'Mail Log'
level: error
headers:
Content-Type: "text/html" Here is the beginning of the email's source:
The interesting part is the
But your tests are done as if it we were using the first structure. |
Actually, Symfony normalize the keys. So using:
is a bad idea. You should use the following configuration instead
|
I updated the PR to reflect this decision |
b64cb29
to
19eaa0f
Compare
@lyrixx Both configurations seem to be the same in your previous comment. |
ahaha, sorry. I edited my comment. Thanks |
Haha I read it twice to be sure. I'm ok with the current configuration, it already worked. Do you need me to test it again? |
I test it :) it should be OK :) |
But if you can, it would be nice ! |
I just tested it, I receive the email as HTML, it's good for me :) |
Thanks for your work on this new feature! |
…lyrixx) This PR was merged into the 3.x-dev branch. Discussion ---------- Add support for headers in native mailer The native mailer is able to have additional headers, but it wasn't possible to give it any headers in the configuration. Swift mailer may have a content_type key but not native mailer. A new "headers" key is now allowed in the handler configuration, so a list of headers may be given to the handler. Only native mailer supports it. Related to #272 Commits ------- 19eaa0f Fix 'Add support for headers in native mailer' 7ecbc9e Add support for headers in native mailer
The native mailer is able to have additional headers, but it
wasn't possible to give it any headers in the configuration.
Swift mailer may have a content_type key but not native mailer.
A new "headers" key is now allowed in the handler configuration, so a
list of headers may be given to the handler. Only native mailer supports
it.
Related to #272