Email pipe to PHP script not getting whole string if email exceeds 1MB

Operating System & Version
centos 7
cPanel & WHM Version
11.108.0.11

masroorejaz

Member
Mar 30, 2023
7
2
3
Karachi
cPanel Access Level
Root Administrator
Hello,

I am using cPanel Pipe to function to my PHP script using the modified following code to insert email to mysqli:

It's working fine. But the problem is if the email attachments crosses 1MB then PHP is not getting the full UTF-8 string (1.png) . It's working fine if email attachments are under 1MB (2.png) .

I am unable to find any solution for it. Please help.

Thank you.
 

Attachments

masroorejaz

Member
Mar 30, 2023
7
2
3
Karachi
cPanel Access Level
Root Administrator
Finally found the solution by using ChatGPT.

Additionally, you may try changing the mailRead function to read the input in larger chunks than 1KB. For example, you can change the line $sEmail .= fread($fp, 1024); to $sEmail .= fread($fp, 8192);, which reads 8KB at a time. This will reduce the number of iterations required to read the email, which might improve the performance.

So I just changed the value of 1024 to 8192 in the following script and now it's working fine: