Skip to content

Attachment id issue #31

@klysiak

Description

@klysiak

Hi,

I received an email with attachments and those were not recognized by your library.
The issue was that originally imap_fetchstructure got the following:

[type] => 3 [encoding] => 3 [ifsubtype] => 1 [subtype] => PDF [ifdescription] => 0 [ifid] => 1 [id] => <> [bytes] => 277320 [ifdisposition] => 1 [disposition] => attachment [ifdparameters] => 1
Your code:
$attachmentId = $partStructure->ifid ? trim($partStructure->id, " <>") : (isset($params['filename']) || isset($params['name']) ? mt_rand() . mt_rand() : null);

was generating empty $attachmentId so if($attachmentId) returned false and the attachments were not processed.

Temporarily I added
$attachmentId = $partStructure->ifid ? ((trim($partStructure->id, " <>") != '')?trim($partStructure->id, " <>"):mt_rand() . mt_rand()) : (isset($params['filename']) || isset($params['name']) ? mt_rand() . mt_rand() : null);

and it is working. I will check if it is causing any further issues.

Maybe you have better suggestion?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions