php-imap icon indicating copy to clipboard operation
php-imap copied to clipboard

Attachment issue - undefined function random_bytes()

Open kashyap-git opened this issue 4 years ago • 6 comments

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

kashyap-git avatar Sep 22 '20 16:09 kashyap-git

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?

bapcltd-marv avatar Sep 23 '20 08:09 bapcltd-marv

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

kashyap-git avatar Sep 23 '20 12:09 kashyap-git

ah; oversight on my part- it's stuck on require-dev, not require.

bapcltd-marv avatar Sep 23 '20 13:09 bapcltd-marv

@Sebi94nbg have a fix for this ready, but need a 3.x branch to target the pull request against.

bapcltd-marv avatar Sep 23 '20 14:09 bapcltd-marv

@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.

bapcltd-marv avatar Nov 16 '20 10:11 bapcltd-marv

Oh, just saw this now. Looks like as I've overseen this mentioning. :-/

Is this still necessary @bapcltd-marv ?

Sebbo94BY avatar Jan 09 '22 20:01 Sebbo94BY