-
-
Notifications
You must be signed in to change notification settings - Fork 858
Issue with Multiple Attachments (First Attachment OK, Second Attachment Corrupted) #666
Comments
I don't know exactly, but in this example "fromPath()" is used?! https://github.com/suzuki/swiftmailer-samples/blob/master/src/120-message-attach.php |
Thanks Voku, you are correct - to add attachments from disk you can use the fromPath method. I tested the example and unfortunately it generates the same error. In my case both attachments are derived from a HTML query report (one is converted to PDF) - so I would prefer not to store them to disk before attaching.
Another thing I have just noticed is that attachments are the same size and should not be. i.e. the PDF file should be larger than the CSV. I checked the contents and it looks like the second file is just a duplicate of the first. So I'm guessing that the way that I'm attaching multiple files is not correct. Maybe it's not possible with Swiftmailer as there are no examples of multiple attachments in the documentation. :-( |
As a painful workaround for this I ended up sending two separate emails with single attachments. I wonder if anyone else has been successful in sending multiple attachments? I'm suspicious that the second attachment is a copy of the first, so maybe the second Swift_Attachment instance was not created correctly. |
@dahomz I have added a test, but it didn't work as expected ... maybe you can take a look at the test, there is something still missing in the reg-ex ... :/ |
It's a problem on Windows os.
Reletad issue: #602 |
I have the same problem, but could identify the issue. If the messages are spooled, the message will be cloned. And during cloning a new _cacheKey is generated. BUT the key is generated in another way than inside the constructor. inside Swift_Mime_SimpleMimeEntity:__construct(): $this->_cacheKey = md5(uniqid(getmypid().mt_rand(), true)); inside Swift_Mime_SimpleMimeEntity:__clone(): $this->_cacheKey = uniqid(); which resulted for me to:
As you can see the same ID is generated, so the first image or attachment will be ok and the data of all other attachments and images are linked to the first rendered one. EDIT: v5.4.2 fixes it. |
It has been fixed in bf40b56 |
I've run into a problem when attempting to attach two files (pdf and csv) into an e-mail. Whichever file I attach first is OK, but the next attachment is corrupted. I've tested/confirmed both single attachments can be sent correctly; the issue only occurs when both files are attached to the same e-mail. Here's a simplified example of my code.
Documentation refers to multiple attaching files from disk, wondered I'm using the attachment instance incorrectly or whether there is an issue.
Assistance appreciated, thanks.
The text was updated successfully, but these errors were encountered: