Not Ticket attachement when PHP-IMAP Enabled

Hello,
i still have some problems that my e-mail-collector is not saving attachments for new tickets while my PHP-IMAP library is avitivated (needed for my microsoft 365 oauth2).
I have this problem for a while back to version 19 or before, i have testet two systems 19 and 20.0.2 with PHP 8.2 and 18 till 20.0.2 with PHP 7.4.33.
My Gmail imap will receive attachments on both systems while the PHP-imap is disabled, as soon as i acitvate it, it fetches the E-Mail Tickets without attachments, the Response-in though, will receive Attachments on all systems, so i believe the problem with the Collect_Ticket_Request, it throughs an error on line 3930 of the emailcollector_card.php

file_put_contents($destdir.‘/’.$filename, $content);

it would not find a file or directory

Maybe some PHP expert is in our group who could help me to find whay the collect_response_in will work with attachments
and the
collect_ticket_request will only create the ticket without attachments, while the php-imap library is enabled.

Hope it was not to confusing.

Jason.

PS
a small Collector protocol

doCollectOneCollector is using method MAIN_IMAP_USE_PHPIMAP=1, access_type=1 (OAUTH2)
Refresh token Microsoft-Alpha
IMAP search array used : array (\n 0 => \n array (\n 0 => 'UNDELETED',\n ),\n 1 => \n array (\n 'SINCE' => '18-Nov-2024',\n ),\n)
Then search string into email header : ! /References.*@55fcf57ffafe96a10e393476667d1f1f12d9aa47/
** Process email #1 - MsgId: cd7e4540678842ef8f9c313ba6e75f54@dw-in.de - Date: Mon, 18 Nov 2024 07:30:19 +0000 - References: NotFound - Subject: TEST Ordner
* Process operation recordevent
Email will have actioncode=EMAIL
We did not find existing actionmail with msgid=cd7e4540678842ef8f9c313ba6e75f54@tt-in.de
Event created -> id=44430
* Process operation ticket
Email will have actioncode=EMAIL
Ticket not found using trackid= or msgid=cd7e4540678842ef8f9c313ba6e75f54@tt-in.de
Ticket created with attachments -> id=1576
Move mail 4331 - cd7e4540678842ef8f9c313ba6e75f54@tt-in.de - TEST Ordner to Archiv
move email 4331
Expunge
type or paste code here

The Problem seems

Its solved for me
in the emailcollector.class at line 3792 was the hint

// filename may be given as ‘Filename’ or ‘Name’ or both
$filename = $params[‘filename’] ?? $params[‘name’];

so i change at lines 3214 and 3363

from

$filename = $attachment->getfilename()

to

$filename = $attachment->getname()

Hello,

Good that you find the solution.
Can you make a PR on GitHub ?
If not I can push it.

Hi,
i allready opened a BUG on Github a couple of weeks ago and mentioned my solution, but i am not sure how to mark it as solved :slight_smile:
I am on a german dolibarr channel as well, and we still discuss about the function getname() , it seems that it does not exist, and are wondering why my solution is working, we want to be sure and give feedback soon.

PS
function getName() does exist
i made a further improvement and adopted the line from 3792 and i think this would be better

$filename = $attachment->getFilname() ?? $attachment->getName();

Remember this was only needed for the PHP library not the native PHP, with the native PHP i had no Problems.

1 Like