Roundcube Community Forum

Third Party Contributions => API Based Plugins => Topic started by: Loguithat1955 on January 02, 2018, 08:58:11 AM

Title: Add Attachment to Mail in compose window
Post by: Loguithat1955 on January 02, 2018, 08:58:11 AM
Is there a function to add a attachment to a empty e-mail, when i have the full path of this attachment on the server? I have seen that there is a function rcmail_save_attachment(), but i allways get a Internal Server Error 500, if i try to use this. i tryed it with:

$attachment = rcmail_save_attachment($fullfilepath, null);
Title: Re: Add Attachment to Mail in compose window
Post by: SKaero on January 02, 2018, 10:21:12 AM
You can add then in the message_compose hook https://github.com/roundcube/roundcubemail/wiki/Plugin-Hooks#message_compose
Title: Re: Add Attachment to Mail in compose window
Post by: Loguithat1955 on January 02, 2018, 01:26:30 PM
If I understand this correctly, this hook is executed when I click on the "create new mail" button. But I have already opened the new, mostly empty, mail. I have placed a new button in the attachment area. This brings me the path to a file stored on the server. This file should now to be attached to the already opened mail, identical to the function how I can attach new files via the normal upload.
Title: Re: Add Attachment to Mail in compose window
Post by: Loguithat1955 on January 02, 2018, 04:49:57 PM
I think, i have found a way to get what i need. But now i get the following error message "
Code: [Select]
PHP Fatal error:  Uncaught Error: Call to undefined function rcmail_filetype2classname()" when i use:

Code: [Select]
$rcmail->output->command('add2attachment_list', "rcmfile$id", array(
            'html' => $content,
            'name' => $attachment['name'],
            'mimetype' => $attachment['mimetype'],
            'classname' => rcmail_filetype2classname($attachment['mimetype'], $attachment['name']),
            'complete' => true), $uploadid);

Do i have to include some file before?

Additionally i get the same error for
Code: [Select]
rc_mime_content_type($filepath, basename($filepath))
Title: Re: Add Attachment to Mail in compose window
Post by: alec on January 03, 2018, 02:21:24 AM
You're using function aliases no longer available in Roundcube 1.3. See https://github.com/roundcube/roundcubemail/blob/release-1.2/program/include/bc.php for replacements.
Title: Re: Add Attachment to Mail in compose window
Post by: Loguithat1955 on January 04, 2018, 11:15:02 AM
Ahhhh thx for this link. Now it works and i have released a new version of the storage plug-in.