php-imap
php-imap copied to clipboard
Attachment issue - undefined function random_bytes()
Environment (please complete the following information):
- PHP IMAP version: ^3.1
- PHP Version: 5.6.28
- Type of execution: Web Server
Describe the bug
As per the description on github main page that php-imap Version 3.x can be used with PHP 5.6.
I have Imap version ^3.1 on my PHP version 5.6.28. But when processing email attachment it causing PHP fatal error stating that PHP Fatal error: Call to undefined function random_bytes() in /php-imap/vendor/php-imap/php-imap/src/PhpImap/Mailbox.php on line 1366
I have checked and found that this(random_bytes()) function is only supported with PHP 7 and later.
Can you please have a look and check if it is actually version issue or my misunderstanding in installation of library?
To Reproduce I am not sure if it is actually version issue but you can try with below version with multiple attachment
- PHP IMAP version: ^3.1
- PHP Version: 5.6.28
The used code: I am using basic example given in documentation. Everything works fine except attachment processing.
The headers of the parsed email, if required and possible (only, if it's NOT confidential):
Not available
Expected behavior To get attachment list atleast.
Screenshots / Outputs N/A
Additional context N/A
random_bytes()
should be getting polyfilled by paragonie/random_compat
when you're running 3.1 under php 5.6.
is the polyfill not loading?
When I have installed lib with composer require php-imap/php-imap
polyfill by paragonie/random_compat didn't install.
I have installed paragonie/random_compat using composer separately and now library works fine. I am not sure why pollyfill is not downloading automatically with command composer require php-imap/php-imap
ah; oversight on my part- it's stuck on require-dev, not require.
@Sebi94nbg have a fix for this ready, but need a 3.x branch to target the pull request against.
@Sebi94nbg I forget where I left the fix but 3.x branch is still needed for backporting, so I can go look for the fix or remake it once you ping me after 3.x branch is made.
Oh, just saw this now. Looks like as I've overseen this mentioning. :-/
Is this still necessary @bapcltd-marv ?