-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attachment id issue #31
Comments
Sure dear. Can you send me one pull request pls ? |
This is a very bad construction |
Yes. So I didnt merged it yet. |
I would suggest doing so, but check: /**
* @param object $structure
* @param array $params
* @return string|null
*/
public static function getAttachmentId($structure, $params): ?string
{
if ($structure->ifid && !empty(trim($structure->id, " <>"))) {
$attachmentId = trim($structure->id, " <>");
} elseif (isset($params['filename']) || isset($params['name'])) {
$attachmentId = mt_rand() . mt_rand();
} else {
$attachmentId = null;
}
return $attachmentId;
} |
@klysiak can you verify the above solution please ? |
I have implemented suggested solution. First impression is good. It is working fine. Please give me few days to verify if all is correct. |
@klysiak okay, Thanks |
@klysiak did you get time check this ? |
If you dont mind, Can you give me an update please ? |
Hello. If the name of the attached file is too long, then the OS does not allow it to be saved. Can the file name be generated randomly, for example through the uniqid function? It would be nice not to save the files, but to get its contents through the method. |
Yes it would be nice. We check the length of the file, if it is too large, then we replace it with a unique value |
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?
The text was updated successfully, but these errors were encountered: