Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

getBody on attachments sends and empty attachment #551

Closed
rabas opened this issue Nov 4, 2014 · 0 comments
Closed

getBody on attachments sends and empty attachment #551

rabas opened this issue Nov 4, 2014 · 0 comments

Comments

@rabas
Copy link

rabas commented Nov 4, 2014

The issue seems to be that calling getBody on Swift_Mime_SimpleMimeEntity before actually sending the email makes the given attachment empty.

Body of the attachment is read from the file, and it is instance Swift_ByteStream_FileByteStream. So when I call getBody it does return a string containing the body of an attachment. But the attachment is empty.

I can reproduce this by calling getBody twice:

var_dump($attachment->getBody());
// Dumps a string that contains attachment body

var_dump($attachment->getBody());
// Dumps an empty string 

As far as I can tell, read method of Swift_ByteStream_FileByteStream does not reset read handle correctly, because when I call $os->setReadPointer(0) before return of the _readStream method of the Swift_Mime_SimpleMimeEntity body is correctly returned each time.

Edit: Swiftmailer version is Swift-5.2.2-DEV and PHP version is PHP 5.6.0

fabpot added a commit that referenced this issue Mar 14, 2015
This PR was merged into the 5.3-dev branch.

Discussion
----------

Reset read pointer

Please reference #551 for description.

Commits
-------

b17fe20 Reset read pointer
@fabpot fabpot closed this as completed Mar 14, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants