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
[GH-28] Allow setting message streams transport-wide or per message #29
[GH-28] Allow setting message streams transport-wide or per message #29
Conversation
… per message via header.
*/ | ||
private function processMessageStream(&$payload, $message) | ||
{ | ||
if ($message->getHeaders() && $message->getHeaders()->has('X-PM-Message-Stream')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw the discussion in #20 about not adding special handling and detecting this in the API instead. However in this csae its necessary, if you have a message stream set as default, then it would be present in the API request, and probably not overwritten by the header that is sent as well.
The style of both files are inconsistent, there are a few tabs and a few spaces lines. My editor wants either one, it would make the diff quite huge. Probably necessary to fix the styling afterwards. |
As mentioned in #28 , our API sending endpoints already support setting the So $message->getHeaders()->addTextHeader('X-PM-Message-Stream', 'your-custom-stream'); This PR would additionally give customers the ability to set the default This could be a useful improvement, but is also a different design compared to what we have been doing for other libraries. @atheken what is your opinion on this? |
@vladsandu for me thats a violation of the Siwftmailer contract. The Message Stream used is interenal to the Transport object. It should not concern the code sending the message. ]The problem becomes apparent when using Mailcoach, which uses Swiftmailer and supports many different Backends, including Postmark. Now the code of Mailcoach will not add setting this header in their code sending messages, because it could also use Mailgun or any other provider. The abstraction should allow this config. How about another approach, where you allow users to set default headers that are attached to all messages via the transport? |
@beberlei sorry for the big delay in replying here. I was on PTO during the past few weeks. I understand your use case now and it definitely makes sense. Comparing the current implementation and the new approach that you suggested (allowing users to set transport-level default headers), I do prefer the new approach more. It would solve a more general problem and allow users to set any default headers, not just If you are interested in contributing for this new approach, I would be more than happy to get it released shortly after. Otherwise, we'll look into adding this in the next few weeks. |
* @param Swift_Mime_SimpleMessage $message | ||
* @return void | ||
*/ | ||
private function processMessageStream(&$payload, $message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make anything private
, you don't know in what ways other users/customers need to customize things.
private function processMessageStream(&$payload, $message) | |
protected function processMessageStream(&$payload, $message) |
See also #33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The methods in this code are all mostly private, i keep to the existing style. No need to combine #33 into this here.
@vladsandu I opened #35 with the option to set default headers. |
Two ways to optionally set the
MessageStream
option on a message:Globally for the whole transport:
Only for one message, by using the header that Postmarks SMTP sending is using:
Fixes #28