Intro

I really didn't intend to much around in the code here, and would really appreciate an evaluation of the issue by someone with Drupal coding experience -- I have none.

Anyway, I've been trying to get Mailsave+Mailhandler+Listhandler+Comment_Upload working so that attachments on an email sent to a list-server will appear in Drupal as attachments on a comment on a threaded forum discussion. That works right now, but only after I made some changes based on 'hunches'--so, take all this with a grain of salt.

This issue is the third I've created or responded to in trying to get this working. The other two are:

http://drupal.org/node/297220
and
http://drupal.org/node/531690

I had to alter code in all three of these issues to reach the point where this works for me. To reproduce my current (apparently working) situation, implement the changes suggested in all three issues -- I don't think the order matters. http://drupal.org/node/531690 seems the most risky.

**
Ok, that out of the way.

After going through the above two issues, I found that links were being created at the bottom of comments on forum threads, as expected, but they linked to the sites/default/files directory, and the files themselves were being saved to the Drupal installation directory, so the links didn't work.

I found this code in the mailsave.module -- it appears to be saving the attachment files:

    // Create temporary name/path for newly uploaded files.
    //if (!$dest) {
      $dest = file_destination(file_create_path($file->filename), FILE_EXISTS_RENAME);
    //}

About the parameter for file_create_path the Drupal API docs say it should be:

"A string containing the path to verify. If this value is omitted, Drupal's 'files' directory will be used."

So I think this line was responsible for the file being saved in the root directory. The module may mean to subsequently have moved the file -- I don't know. I modified the line above to read:

    // Create temporary name/path for newly uploaded files.
    //if (!$dest) {
      $dest = file_destination(file_create_path().'/'.$file->filename, FILE_EXISTS_RENAME);
    //}

Making that change along with the changes described in the other two issues linked to above, seems to have things working...

Comments

tobias’s picture

Hi there - I was just looking into this as well. I'd like comments to support attachments, on the website as well as by email. Is there a way to do this now without hacking code?

Thanks,

Tobias

bibstha1’s picture

mailsave.module is working fine without above mentioned change.