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

[DOCUMENTATION] attachment names have been changed to *.bin since 3.1.0 #533

Closed
gitstashgithub opened this issue Jul 27, 2020 · 7 comments
Closed
Labels
documentation Related to the documentation.

Comments

@gitstashgithub
Copy link

Hi,

3.1.0 changed the downloadAttachment function in Mailbox.php. Now the attachment file name is randomstring.bin, rather than the original file base name and extension name. This change is also not listed in the release log.

Thanks

@gitstashgithub gitstashgithub added the needs investigation This will be tested / debugged or checked out. label Jul 27, 2020
@bapcltd-marv
Copy link
Contributor

the change is not a bug, this was done to fix #448, as well as relating to the bugs that occur with emails having multiple attachments with the same filename overwriting each other.

@bapcltd-marv
Copy link
Contributor

documentation and release notes are a separate matter, however.

@Sebbo94BY Sebbo94BY added documentation Related to the documentation. and removed needs investigation This will be tested / debugged or checked out. labels Jul 27, 2020
@Sebbo94BY Sebbo94BY changed the title [BUG] attachment names have been changed to *.bin since 3.1.0 [DOCUMENTATION] attachment names have been changed to *.bin since 3.1.0 Jul 27, 2020
@gitstashgithub
Copy link
Author

Thank you for your reply. Since the attachment extension name was correct, my code only updated the attachment base name, so this fix actually broke it. It's very easy to fix, but I just think it's worth to mention any possible breaking changes in the release notes.

@aheman
Copy link

aheman commented Sep 7, 2020

Thank you for your reply. Since the attachment extension name was correct, my code only updated the attachment base name, so this fix actually broke it. It's very easy to fix, but I just think it's worth to mention any possible breaking changes in the release notes.

I've just stumbled into this change myself. It seems like IncomingMailAttachment->fileExtension worked for me for referencing images the extension for jpg, gif, png, but something about a pdf is not returning pdf but instead .bin. I must be missing something obvious for the fix.

@bapcltd-marv
Copy link
Contributor

can't recall 100% off the top of my head, but it may be related to fileinfo rather than looking at the original extension ?

@aheman
Copy link

aheman commented Sep 8, 2020

It seems like whatever I was doing originally to check the extension that I had wasn't doing anything any better than just taking it off the filename at this point.

@Sebbo94BY
Copy link
Collaborator

There is only the documentation in form of code:

if (true == $this->getAttachmentFilenameMode()) {
$fileSysName = $attachment->name;
} else {
$fileSysName = \bin2hex(\random_bytes(16)).'.bin';
}

...but this might will change in the future again: #645

So at the moment, you can for example change this behaviour to use the original file name like this:

// Create PhpImap\Mailbox instance for all further actions
$mailbox = new PhpImap\Mailbox(
	'{imap.gmail.com:993/imap/ssl}INBOX', // IMAP server and mailbox folder
	'[email protected]', // Username for the before configured mailbox
	'*********', // Password for the before configured username
	__DIR__, // Directory, where attachments will be saved (optional)
	'UTF-8', // Server encoding (optional)
	true, // Trim leading/ending whitespaces of IMAP path (optional)
	true // Attachment filename mode (optional; false = random filename; true = original filename)
);

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

No branches or pull requests

4 participants