Author Topic: Add Attachment to Mail in compose window  (Read 2541 times)

Offline Loguithat1955

  • Jr. Member
  • **
  • Posts: 45
Add Attachment to Mail in compose window
« 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);

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,518
    • http://SKaero.com/
Re: Add Attachment to Mail in compose window
« Reply #1 on: January 02, 2018, 10:21:12 AM »

Offline Loguithat1955

  • Jr. Member
  • **
  • Posts: 45
Re: Add Attachment to Mail in compose window
« Reply #2 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.

Offline Loguithat1955

  • Jr. Member
  • **
  • Posts: 45
Re: Add Attachment to Mail in compose window
« Reply #3 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))

Offline alec

  • Hero Member
  • *****
  • Posts: 1,146
Re: Add Attachment to Mail in compose window
« Reply #4 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.

Offline Loguithat1955

  • Jr. Member
  • **
  • Posts: 45
Re: Add Attachment to Mail in compose window
« Reply #5 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.