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.
Comments
Drupal 7
is there a similar procedure for Drupal 7. Feeds_comment_processor is not available for D7.
κατασκευή ιστοσελίδων
Like I mentioned in the post,
Like I mentioned in the post, and you seem to have noticed, some requisite modules have not been ported to D7. I don't know of any work-arounds. There is a partial port of feeds_comment_processor to D7 at https://drupal.org/node/1051510
Import error in D7
Hi, your last post suggested that the D7 functionality was dependent on the port of feeds_comment_processor. Well as of now (March 2012) this is available. However, importing the comment emails fails with the error:
So I am able to connect to the mailbox where the comments are retrieved from, but not able to import them.
Can you please suggest what I should check/change to make the import work?
Fyi if you get a drush make error like
Unable to determine project type for drupal
Just upgrade your drush_make
I upgraded to this and it worked.
http://ftp.drupal.org/files/projects/drush_make-6.x-2.x-dev.tar.gz
Alfred Nutile
http://twitter.com/alnutile
I was going to add a Profile install so after your make script
you can then choose that profile install to enable all the modules.
Is it something someone else is working on already or should I give it a go?
Also I made a fork of this for og_notifications with http://drupal.org/project/notifications_team
module to make the whole group system work. I guess I can make a profile for that as well and add a child page to this page to talk about that later this month.
Thanks for your work on this!
Alfred Nutile
http://twitter.com/alnutile
Sounds good, no work had been
Sounds good, no work had been done on an install profile as far as I know. Thanks.
Tokens in the body
is there a way to use tokens in the body.
For example if you use the drupal profile module you could write this in the email.
Dear [profile:first] [profile:last]
I am looking now but just figured I would ask.
Alfred Nutile
http://twitter.com/alnutile
You can use the Token filter
You can use the Token filter module if you'd like users to be able to insert tokens, but I think what you really want to do is edit the templates for Notifications 6.x-4.x / 7.x-1.x. I know the following thread applies to 7.x-1.x, but I can't recall if 6.x-4.x works the same way: http://drupal.org/node/1261822
MailComment
Just tried setting this up with the new MailHandler-2.2, got the following error when attempting to configure MailComment:
user warning: Table 'lowell.mailhandler' doesn't exist query: SELECT mid, mail FROM mailhandler ORDER BY mail in /var/www/sites/all/modules/mailcomment/mailcomment.module on line 196.
The table does indeed not appear to exist.
Please post any issues like
Please post any issues like this in the appropriate issue queue. Thanks.
The link to Mailhandler INSTALL.txt is wrong
The right one is: http://drupalcode.org/project/mailhandler.git/blob/refs/heads/6.x-2.x:/I...
Sorry, can you please tell me
Sorry, can you please tell me what's wrong with the current link? They look the same to me...
Great project! Can we moderate messages?
I'm very excited about using this approach for email-driven workflow! Thanks to everyone who contributed to this, especially Dane Powell.
My question is about moderation. Would it be easy to have all incoming emails unpublished by default? I would then need an easy way to see the list of these emails so I could approve/publish them one by one.
I plan to use this as a replacement for Google Groups.
Any thoughts or suggestions (or caveats)? Thanks
You may want to look into
You may want to look into Workbench Moderation for something like this!
Richard Schulte
Can we moderate messages?
"Finally, note that this is only currently possible with Drupal 6..."
yet Workbench Moderation is only for D7, so that would not seem to work as a solution for moderation with email-driven workflow.
this functionality can be
this functionality can be adapted to 7 quite readily. mailhandler has a full d7 release.
Richard Schulte
Mailcomment and OG D7 status
I'm trying to config the mailcomment module with OG and D7. What is the status? Is it already working? There were unmet dependencies. I cannot see anywere clearly where this has been fixed or not. Anyone knows?
MailComment, OG, and OG Mailinglist
Hi
I've got both MailComment and OG Mailinglist installed. MailComment is working. OG Mailinglist is partially working.
MailComment sends emails to node subscribers when comments are added to a node (where the comment is entered either directly in drupal or comes in via an email reply to an email MailComment had sent, after processing by the associated feeds importer). It doesn't (at least out of the box) include the comment subject or text in the emails it sends out. It does link the incoming email (containing a reply to a comment) to the appropriate comment. It doesn't send emails when nodes are created, so there is no way (out of the box) to reply, via email, to the node itself. It also doesn't automatically subscribe users to nodes as the nodes are created, so users only get emails about comments added to nodes once they subscribe themselves to the node.
OG Mailinglist, as the name says, is integrated with OG. It sends emails to OG group members when a node is added to a group, and automatically subscribes all group members to the node that just got created. The node can be created either directly in drupal, or a group member can send an email to a group's email address to create a new node in the group. A recipient can reply to the email they got, and the reply will turn into a comment added back to the node. I don't have the reply processing working yet, so I cant verify this, but that is how it supposed to work. I assume OG Mailinglist similarly sends emails when comments are added to nodes (either directly in drupal or as a result of email processing), and replies to those emails are linked to the appropriate parent comment.
OG Mailinglist uses a lot of non-drupal SMTP connectivity to make this all work, and that was very challenging for me to get working in my shared hosting environment. MailComment is easy to set up, and uses standard drupal STMP pathways.
If MailComment were OG aware (which would take quite a bit of work to make happen), and if it would send node/comment body text in the emails it sent (should be easy enough to arrange), I be delighted. But lacking those features, OG Mailinglist seems to offer the more robust workflow support.
MailComment uses Message Notify or Notifications to send emails. Might be possible to use Rules to get those emails sent to group members. Haven't dove into that approach yet. If anyone knows if that is a viable option, please let me know.
Thanks