Skip to content
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

saveAttachments problem #238

Closed
tolgacinar opened this issue May 22, 2019 · 4 comments
Closed

saveAttachments problem #238

tolgacinar opened this issue May 22, 2019 · 4 comments

Comments

@tolgacinar
Copy link

Save attachments with this function but cant open files. Files are breaking

@YaWK
Copy link

YaWK commented Sep 11, 2019

I've had the same issue. You need to base64_decode the attachment body. I've changed the line of file_put_contents[...] in ImapClient\SaveAttachments method to this:

This solved the problem for me:
file_put_contents($dir.DIRECTORY_SEPARATOR.$newFileName, base64_decode($attachment->body));

@ggiacomoo
Copy link

thanks, why not pulled?!?!

@tuptuptup
Copy link

tuptuptup commented Dec 29, 2020

@YaWK @ggiacomoo It's a good solution, but not for each attachment. Some of attachments need quoted_printable_decode.

		if (base64_decode($attachment->body, true) == true){
			file_put_contents($dir.$newFileName, base64_decode($attachment->body););
		}else{
			file_put_contents($dir.$newFileName, quoted_printable_decode($attachment->body));
		}

@tolgacinar
Copy link
Author

Solved.

#238 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants