Setting up an email-driven workflow with attachments (2.x)
This document describes how to assemble and configure a number of Drupal modules to achieve a completely integrated email-driven workflow- that is, the ability to reply to nodes and comments via email or web interface with complete support for attachments and revision-tracking. This could be used to setup a hybridized forum / mailing list, where members can receive notifications of new topics and reply to them via email. It could also be used with modules such as Case Tracker and Case Tracker Plus for completely integrated issue-tracking via email.
Background
A number of Drupal modules make this email-driven workflow ("mailflow" for short) possible. Notifications and Messaging have long allowed users to subscribe to posts and receive notifications via email (among other means). Mailhandler allows users to submit new nodes via email. Mailcomment fills the gap between these modules by adding threading information to outgoing messages and parsing this information when a user replies via email.
This workflow was possible using the combination of Mailcomment 1.x, Mailhandler 1.x, Mailsave 1.x, and Notifications/Messaging 2.x (collectively "mailflow 1.x"), but was a bit of a kludged-together solution. The recent release of Mailhandler 2.x has greatly streamlined the process. This document describes the mailflow 2.x setup.
Note that some modules are currently in development and should probably not be used in production environments. Additionally, not all modules might be necessary for your use case (i.e. if you don't care about attachments), and you may want to adjust some settings when moving to production (i.e. the minimum refresh period).
Finally, note that this is only currently possible with Drupal 6, as a number of required modules have not yet been ported to D7 (notifications_files, driven, and comment_driven).
Dependencies
Simply run this Drush makefile to install all required dependencies:
core = 6.x
api = 2
projects[] = drupal
; Modules
projects[notifications] = 4.x-dev
projects[messaging] = 4.x-dev
projects[notifications_files] = 4.0-beta6
projects[mailhandler] = 2.3
projects[mailcomment] = 2.0
projects[comment_driven] = 1.x-dev
projects[driven] = 1.x-dev
projects[ctools] = 1.x-dev
projects[feeds_comment_processor] = 1.0-beta1
projects[feeds] = 1.0-beta11
; Fixes Driven reporting all files removed and added
projects[filefield][version] = 3.10
projects[filefield][patch][] = http://drupal.org/files/issues/filefield-1132622-8.patch
projects[] = job_scheduler
projects[] = autoload
projects[] = token
projects[] = cck
projects[] = libraries
projects[] = fcp_files
; Libraries
libraries[phpmailer][download][type] = "get"
libraries[phpmailer][download][url] = "http://downloads.sourceforge.net/project/phpmailer/phpmailer%20for%20php5_6/PHPMailer%20v5.1/PHPMailer_v5.1.tar.gz?r=http%3A%2F%2Favatar.rice.edu%2Fjenkins%2Fjob%2Faegir_platforms%2F81%2Fconsole&ts=1323290054&use_mirror=voxel"
libraries[phpmailer][directory_name] = "phpmailer"
libraries[phpmailer][type] = "library"Setup Procedure
Enable the following modules (this is not an exhaustive list- just the "path of least resistance" that should automatically enable all other dependencies): Notifications UI, PHPMailer, Mailhandler Default, Mailcomment Default, Notifications Files, Comment Driven NodeAPI, Driven CCK properties, Feeds Comment Processor Files, Libraries.
Note: at this point, you may want to clear all caches, to ensure that new classes and plugins defined by the above modules get picked up. For instance, you may get a WSOD related to the Notifications_Event class not being found, which can be resolved by clearing caches.
Now configure the settings at the pages below:
Notifications and messaging
admin/messaging/settings : Select PHPMailer as the default send method
admin/messaging/settings/method/phpmailer : Check "include attachments"
admin/messaging/notifications : Check "notify poster of own posts", "immediate sending", and "full user data" (not strictly necessary)
admin/messaging/settings/method/mail : Configure the return address as appropriate
Content Types / Driven
admin/content/node-type/story : You can choose what to do with node attachments when new comments are posted
admin/content/node-type/story/fields : Add a filefield- make sure to permit all file types, and allow unlimited values
admin/content/node-type/story/driven-props : Enable driven properties, and choose the properties as you'd like - be sure to at least choose the filefield you just created.
Input formats
Mailhandler and Mailcomment provide some input filters that will strip things like signatures and other gunk ("On April 15, Dane Powell wrote..."). Note that the full body of the original email is still stored in the database, but these filters (just like the "Filtered HTML" and other default filters) simply prevent this gunk from being displayed when posts are viewed. The available filters are Mailhandler signature separator, Mailcomment basic message cleaner, and Mailcomment extra message cleaner.
If you want to create such an input format, you can do so at admin/settings/filters/add . Be aware, however, that an improperly configured input filter can be the cause of great frustration, causing posts with blank bodies, etc... So it might be wiser to finish this setup process without creating an input format, make sure everything works, and then come back and create a Mailhandler input format.
Mailhandler / Mailcomment
Follow the "Quick setup" instructions in the Mailhandler INSTALL.txt to set up a mailbox and a Mailhandler Feeds Importer for nodes, and follow the Mail Comment INSTALL.txt to configure Mail Comment and set up a Mail Comment Feeds Importer for comments. Be sure to map attachments to the Filefield you created.
You're all set! Now it's time to test...
Testing procedure
Create a new story node by email
Send an email to your test inbox- include an attachment or two to confirm that attachments work. Use the Feeds importer for nodes that you created above (import/mailhandler_nodes) to import this email as a new node. Alternately, it will automatically import at your next cron run if you selected "As often as possible" in feed refresh period.
Note that Mailhandler lets you "command" properties of the node such as status, taxonomy, etc... - for these commands to work, they must be mapped in the processor.
Get notifications of new posts and changes
Hopefully you successfully created a node. Now go to the node and choose "Subscribe to: This Post". Try adding a new comment. Note that you can choose which attachments to resend with notifications (if allowed), and upload new attachments (they will be attached to the parent node).
Reply by email
Hopefully you got an email notification of your comment, with the line "((( Reply ABOVE this LINE to POST a COMMENT )))" towards the top. Do that now, and include an attachment if you want. Then go back to your site and run the comments_by_mail importer and you should see this reply posted as a comment under the original comment, and the attachment should have been added to the parent node, with the change being noted in comment driven.
Modules
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion