-
-
Notifications
You must be signed in to change notification settings - Fork 859
Multipart message is build up incorrectly #775
Comments
I think the problem is in Swift_Mime_SimpleMimeEntity::setChildren(), so this could relate to #744 . $this->_children = $immediateChildren; //$children; and the dumpMsg() code above will output: /*
multipart/mixed
multipart/alternative
multipart/alternative
text/plain
text/html
text/calendar
application/ics
*/ Which is incorrect, and the same as how the whole mime message look like. Also, the method setChildren() has a comment in it: // TODO: Try to refactor this logic Googling that revealed issue #434 which has a possible solution. |
A simple workaround to this problem is to introduce a new method for setting childrens:
This will keep backward compatibility (no existing project would broke), no redesign required, yet people who want to build complex massages or keep the ordering of attachments would be able to do so by creating MimeParts in advance and adding them to the Message at once with this. What do you think? |
I'm closing this issue as it's going to be fixed by Symfony Mailer/Mime, which will replace Swiftmailer eventually. |
This PR was merged into the 4.3-dev branch. Discussion ---------- Mime messages | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | many on Swiftmailer | License | MIT | Doc PR | upcoming As announced today at SymfonyLive Lille, here is the new MIME component. This PR is one step towards the new Symfony Mailer (announced at Symfony London). It started as a fork of Swiftmailer, but soon enough I rewrote almost everything to make it (hopefully) better and more flexible. I've removed all the complexity of Swiftmailer when it comes to multiparts for instance. Some big differences with Swiftmailer: * Way less complexity (no crazy dependency injection when not needed, less interfaces, no cache) * Plain data object and no state (out are the observers for charset and encoding, in are POPO and serializable objects) * No magic regarding multipart management, but a nice wrapper for the most common use cases swiftmailer/swiftmailer#434 swiftmailer/swiftmailer#775 swiftmailer/swiftmailer#946 swiftmailer/swiftmailer#615 swiftmailer/swiftmailer#184 swiftmailer/swiftmailer#56 and probably many others * More Symfony-like * Messages are built on-demand and we do not mess up with your headers/body (Swiftmailer add headers and change yours, but here, we generate needed headers when converting the message as a string, they are not stored -- it means for instance that generating an Email twice will give you 2 different Date headers) * and probably more that I don't remember right now I've also kept some nice features from Swiftmailer like support for any charset. More information on the slides: https://speakerdeck.com/fabpot/2-new-symfony-components-httpclient-and-mime Commits ------- ee787d1 [Mime] added classes for generating MIME messages
I've noticed that multipart messages are handled wrong. The children are added as they should, but when the message is built, an extra, unwanted level is added, wonder why?
Here's a simple code to reproduce the error:
The text was updated successfully, but these errors were encountered: