UPDATE - mailsave is now an official Drupal contribution and you can download the latest versions directly from the mailsave project page.
This also means that if you experience any problems or find a bug then you can raise issue requests directly at the project page.
I am emailing this post in to the website, via my new mailsave module!
mailsave works with mailhandler and will save all the incoming attachments. If you also have image installed then you can choose to have emails that contain a jpeg turned in to an image node, complete with thumbnail. The rest of attachments then get saved as normal.
Ok - going to hit send now, and then type the rest of this post on the web...
This module replaces my earlier code that actually modified mailhandler itself. While that worked (and certainly let me send in a few pictures!) when I posted a reference to it at drupal.org someone suggested that it would be better if it were a separate module.
I am only just learning to write modules, so this seemed like a nice challenge, and I have my first version of mailsave ready and attached to this post.
Unlike my original code, that relied on a modified mailhandler, mailsave is completely separate and interacts with mailhander via hook_mailhandler and hook_nodeapi. The first hook fetches the attachments out the message body, stores them, and converts the node to an image if required. The second hook is processed as part of the save and attaches the remaining files.
If image isn't installed then all the files just get attached.
Attached files are stored in their own folder underneath the drupal_user_files folder so they can be kept separate from regular uploads.
So far it seems ok, so I'm going to leave it running for a while, and see if it is working right (and if anyone else wants to download it!)
And yes, it is for 4.6, and I know 4.7 is coming out, but I haven't got round to upgrading, and Nikki will probably kill me if I mess the main site up now! But when I go 4.7 I will update it!
Notes...
Comments
Not inserted into {files}
Hi,
I've installed mailsave, and the attachments are saved correctly into the selected folder. However, the information about the attachments isn't stored into the files table (and I've fixed the code on line 278 so that it excludes the download column).
Is there any fix to this issue?
Thanks.
Database question for Mailsave
I am having trouble with the Mailsave module and civicspace .84.
The definition of my files table does not include a downloads column and therefore when I try to use Mailsave with Mailhandler I get a SQL error as follows:
Unknown column 'downloads' in 'field list' query: INSERT INTO files (fid, nid, filename, filepath, filemime, filesize, downloads, list) VALUES (63, 76, 'pdficon.gif', 'files/mail/pdficon_0.gif', 'image/gif', 658, 0, 1) in C:\var\www\html\cupe4222\includes\database.mysql.inc on line 66.
Any one know where the create table for the Downloads column comes from?
Any help wouyld be most appreciated!
Brian
Hmmm
A very quick reply, as I need to debug this properly when I have time, but try changing line 278 of
mailsave.modulefromdb_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize, downloads, list) VALUES (%d, %d, '%s', '%s', '%s', %d, 0, %d)",to
db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize, list) VALUES (%d, %d, '%s', '%s', '%s', %d, %d)",I think I know what I've done here, but need to debug properly! I am using the download module to count downloads, and that (I think) added the extra field to the files table. I based
mailsaveon the structure offilesas it was on my system, and missed thatdownloadsisn't a normal part of it! Therefore I need to update mailsave to work using the "standard" drupal files table.No-one else has commented on this, so either everyone else is using download too, no-one who has downloaded mailsave has used it, or people think it doesn't work and never told me!
Could you /please/ update
Could you /please/ update this for 4.7 sometime soon? :)
At some point...
When I finally upgrade the site to 4.7 then if I can I will update mailsave. At the moment I just don't have time to tackle it though! There was a project specifically for 4.7 called mobile media blog (mmb). This uses the same code as mailsave - I'm not sure how far its development has got though, but you might want to check it out.
Work in progress...
Along with the flash module, mailsave has finally started the migration to 4.7. So far so good, without too much effort I already have a version that is intercepting images and doing its conversion stuff! Watch this space...
mailsave now available for Drupal 4.7
I have just uploaded the first version of mailsave for Drupal 4.7. You can get it here.
6.16
I hear that the 6.16 is out, is it possible to get mailsave for it? Sorry if it`s a dumb question, I`m new to this..
Neat concept
I look forward to trying you module. You said
>>It borrows from the code that I wrote, which I'm quite chuffed about.
But remember, imitation is the sincerest form of flattery, and cross-pollination of ideas and effort is what makes open-source software so neat. Hopefully they give appropriate attribution to you and your work.
gil
chuffed -- To be very pleased, proud or happy with yourself
Thats the definition from a dictionary. I at first thought chuffed was a bad feeling. Given the context, that seemed wrong and was. I wonder if the 4.7 media module is as far along as mailsave.
Not sure where mobile media blog is up to!
I was asked if I'd like to help out with mmb. In principle, I'd love to, in practice, with new baby in the house I'm just not going to have time to do any useful work! I'm not sure where it is up to...
!!
I guess that may be "chuffed" is a bit of UK expression?? But yes, I wasn't upset that someone borrowed my mailsave code. And all of my Drupal development so far borrows from other code in one way or another!
another must-have drupal
another must-have drupal module for me. Though it's sitll in eraly development, I will try that out soon. Bookmarked this page with delicious.