Last updated May 16, 2011. Created on August 6, 2009.
Edited by Hanno, tallsimon, donquixote, chrisshattuck. Log in to edit this page.

On this page

  1. Installing Drupal
  2. Enabling the required modules
  3. Configuring the Mailhandler module
  4. Testing the Mailhandler module
  5. Setting up messaging
  6. Setting up notifications
  7. Configuring the Mail Comment module
  8. Creating a forum
  9. Testing the Mail Comment module with the forum
  10. Altering message templates
  11. Configuring cron to run automatically
  12. Caveats and issues with this tutorial

These instructions explain the process of installing and configuring Mail Comment to create online forums that allow full inbound and outbound email participation. Participants receive copies of new forum posts by email, and if they reply to the emails, the replies are posted to the forum. The result is a forum that doubles as a Listserv.

Installing Drupal

For this walkthrough, we will start with a freshly installed portal of Drupal 6.13. To start off, all I have done at this point is to log in as Admin, go to Administer> Site Information, and give the site a name ("email-forum portal") and a real email address.

Enabling the required modules

In that Drupal installation, download the following modules (in this case, using those modules that were current as of November 2009):

Enable these modules at Administer > Site building > Modules:

  1. Mailhandler
  2. Messaging
  3. Simple Mail
  4. All of the modules in the Notifications group except for Notifications Lite.
  5. Token
  6. Mail Comment

Configuring the Mailhandler module

The next step is to configure the Mailhandler module and create an entry for the mailbox that you will use. In other words, telling mailhandler about the existing email address that the system will use for people to mail their posts IN to the system.

  1. You must go and create an email box on a mail server that will serve as the box for these posts to be sent into the system. For the purposes of this walkthrough, I created an email box on an inexpensive hosting service called BlueHost, which, like many hosting companies, allows you to create email accounts on the domains they host. Note also that I am choosing to use the IMAP protocol for connecting to the account, and I am choosing to use SSL (I believe that my drupal hosting company is only allowing this kind of connection to be made when SSL is used.)
  2. Go into that email account that you created, and delete all emails that might be sitting in the inbox by default.
  3. In your Drupal portal, go to Content > Mailhandler mailboxes
  4. Click Add Mailbox.
  5. Here enter all the information about the email account that you created. See illustration below. The below entries are for my example account - naturally, replace the entries with your own. Leave all entries untouched except for these:
    1. In "email address," I enter the account's email address:
    2. For "Folder," I leave it untouched, as "INBOX."
    3. For "POP3 or IMAP Mailbox," I choose IMAP.
    4. In "mailbox domain" give the domain of the mail server, in my case
    5. In "mailbox port" give the communication port that is used by the email server. In my case, since I am using IMAP and using SSL, my hosting company instructed me that the port is 993..
    6. In "emailbox username," enter the username for logging into the email account. In my case, but not necessarily in yours, my provider has the email account logged into by using the full email address but substituting + for @: therefore, I use
    7. In "mailbox password" type the password that you had given for that email account.
    8. In "extra commands," you will usually only need to enter these additional commands for the email call in some circumstance, for instance if you are using SSL. I am using SSL, so I enter: /ssl/novalidate-cert
    9. Make sure that "delete messages after they are processed" remains checked.
    10. Make sure that "Message authentication method" is set to "MailComment Default". Otherwise, mailcomment will not authenticate the message and will tell the user that there was an error.
  6. Save these settings. To see an image of how my mailhandler configuration looked, click here.
  7. Though you have just saved them, you now want to test to see if the portal is able to connect to the email account with these settings, so choose Edit for that mailbox once again, and at the very bottom click the Test Connection button. Ideally the portal will display the message: "Mailhandler was able to connect to the mailbox."
  8. TROUBLESHOOTING: If you got errors or the system hangs for a long time, then carefully check all the settings, and also consider if your servers or host are blocking the ports or protocols, requiring you to choose a different arrangement for POP/IMAP or a different decision about using SSL.

Testing the Mailhandler module

Optional step: Testing the function of Mailhandler's function by using your new Mailhandler mailbox to submit stories to your portal by email.

NOTE: This step is not required. It is good to do it if you are interested in better understanding the functionality of the Mailhandler module, or if you are trying to be extra careful about confirming that each of the parts of Mail Comment are working at this point in the installation:

  1. Since you have your Mailhandler mailbox configuration set up correctly now, we will experiment with it by setting up your portal so that when a registered user of the portal sends an email to the email address, the email is automatically converted to a Story, posted on the site, and promoted to the home page.
  2. Because this function will only accept emails when they are emailed from an email address that is that of a registered account on the portal: Go to the admin account that you have been using on the account, and ensure that the email address associated with "admin" is your own email address.
  3. Go to Messaging & Notifications > Mail Comment and select turn on Passthru to mailhandler module, also set here the default mailhandler authentication during passthru to Mailhandler Default. This will prevent error messages for new posts submitted via email that do not include the authentication string that MailComment looks for. Failing to do this will result in authentication error emails as described at

    However if you will only use mailcomment for replies to posts online, then you can set this to off. It seems some people have found that without setting this to off, their messages are always posted as new messages rather than replies.
  4. Go to Mailhandler and edit the mailbox that you created. Find the entry for Default Commands. Into that box, type the following commands, each of the three on a new line. These tell Mailhandler that with an incoming email, make it into a story, set it to promote to home page, and set it to published (i.e. a status of 1):
    type: story
    promote: 1
    status: 1
  5. Now, emailing from the email address that you earlier set to be the email for the portal's admin account, send an email to the email address of the mailbox that you configured, with a subject of "Spring picnic a universal success" and a body of "Our club's Spring Picnic was hailed by all as the best in years."
  6. Once you have sent that email, we know that the email is sitting in the emailbox of the mailbox. Definitely don’t go check that account's email, which might mark the message as "read." Instead, go to mailhandler, and in the line next to your mailbox, click the "Retrieve" link.
  7. You should see a progress bar and the email will be read from the email account, processed by mailhandler, and deleted from the email account (since you configured it to do so earlier.)
  8. Now, provided that your site's home page has not been changed to something other than simply "node" (you can check that at the Site Information page) -- the next time you visit your site's home page, there should be your new story promoted to the home page.
  9. TROUBLESHOOTING: Didn't work? Check to make sure that you entered the three commands correctly, and make sure that the email address that you send the story in from is indeed set as the email address of the admin's portal account. Also, make sure you didn't type something into the mailbox configuration entry for "From header." That should be blank, because then Mailhandler will look in the incoming email's "from" line to get the email address that will determine which portal user should have the new story attributed to them.
  10. Important: In the above step you have experimented with and tested mailhandler's ability to submit stories via email. Now we want to disable that function -- we are not here to set up email story submission but to set up Mail Comment. So, go to Mailhandler, edit the mailbox that you created, and go to the entry for Default Commands. Delete everything in that box and Save the changes to your mailbox configuration.

Setting up messaging

  1. Go to administer > messaging & notifications > messaging settings.
  2. Under "Default send method," click "Mail" and click Save Configuration.
  3. Then click the send methods tab, and make sure that for the different send methods, the filter that is specified is "Messaging plain text."
  4. Again click "Save configuration."

Setting up notifications

  1. Go to Administer > Messaging & Notifications > Notifications settings.
  2. Check the boxes for "Notify poster of own posts." Leave "immediate sending" un-checked.
  3. Under "Default send interval," choose "Immediately." This is different from the "immediate sending" check box higher on the page, which you left un-checked.
  4. Click "Save configuration."
  5. Click on the Content Subscriptions tab. This is where we specify which types of content can be "email-subscribed" to. The only change for this page is to uncheck the check box next to "Author," since we won't be offering subscriptions that way. Only "Thread" and "Content type" should be checked. Click "Save Configuration" at the bottom.
  6. Click on the "User Interface" tab. In "Visible subscription types," uncheck "Author" and at the far bottom click "Save configuration."
  7. Now we need to change a couple of permissions so that authenticated site users have the ability to "subscribe" to content and maintain their subscriptions. Go to Administer > Permissions and:
    1. in the section for Notifications module, check the "authenticated user" column boxes for "maintain own subscriptions" and "manage own subscriptions."
    2. in the section for Notifications_content module, check the "authenticated user" column boxes for "subscribe to content" and "subscribe to content type."

Configuring the Mail Comment module

  1. Go to Administer > Messaging & Notifications > Mail Comment.
  2. Under Mailhandler Inbox, ensure that the mailhandler inbox that you configured is chosen.
  3. Leave expiration time set to Never.
  4. You can leave "Server string for message ID" as ""
  5. Leave Message Cleaner set to "off."
  6. For "Mail Comment Content Types," choose "Forum Topic."

Creating a forum

This forum is where the email-enabled discussion will take place, for the purposes of this documentation. When your system fully works, you may instead choose to have Mailcomment work in some other part of your site.

  1. Ensure that the Forum module is in fact enabled. Go to Administer > Modules, find "Forum," and check it (and any of the modules that it requires) and then click "Save configuration."
  2. Go to Administer > Forums. Click the "Add forum" tab. In "Forum name," give it a name of "Discussion Forum." Leave other entries unchanged, and click "Save."
  3. We want it to be easy to access this forum, so let's put the entry for this forum on a menu at the left. First, take note of the path of the forum that you just created, by clicking the link to that URL and seeing the end of the URL at the top, which is the path. In my case, the path is forum/1. So, go to Administer > Menus, click Add Menu, create a new menu called Main Menu, click Add Item, and have your new item have the path forum/1 and the name "Discussion Forum." Click Save Configuration, and lastly go to Administer > Blocks, and next to Main Menu, specify "Left sidebar," and click "Save blocks" at bottom. Your new menu, with the link to the forum, will appear in the left nav bar. Click your portal's name or logo at top to go to the home page, to get away from the strange blocks-preview screen.

Testing the Mail Comment module with the forum

Create a few test users, go the users you want to participate, and subscribe them to "Forum topic posts:"

  1. Go to Administer > Users and create a couple test user accounts, perhaps each with a different webmail account (Yahoo, Gmail, etc.) These will help you with testing and learning about the behavior and cosmetics of the posts in different email clients.
  2. Logged in as your admin account, go to My Account > Notifications tab > Content type sub-tab and put a check next to "Forum topic."
  3. To subscribe the other users that you created, you can either simply do them while still logged in as Admin, by going to administer > users, clicking the user's name, and going to Notifications tab, Content type sub-tab, and checking Forum Topic and saving. (Or, if one logs in to the portal as the actual user, they can go to My Account > Notifications tab > Content type sub-tab and put a check next to "Forum topic.")

Create a test thread and carry out a test conversation using the email-enabled forum.

  1. Log in as the administrator. Go to your discussion forum. Click the link to "Post new forum topic." Give it a Subject like "Home Decorating Tips and Tricks" and a body like "Have decorating ideas to share? Post them here!"
  2. The email notification of this new topic will not be sent out until Drupal makes its "cron" run. Later we will configure your portal to carry out its Cron tasks every five minutes, one minute, or whatever you prefer. However, while we are still testing, we will simply run Cron manually each time we want it to process incoming and outgoing emails. SO: Go to Administer > Status Report and click on the "Run Cron manually" link in the Cron section.
    (Note: To make testing easier, you may want to create another entry in the Main Menu that you created earlier, with menu item's title being "Run Cron" and the path being: /admin/reports/status/run-cron … Then each time you need to run Cron to test the workings of the email, you can just click this link. In an actual live site you would not have this link visible, and you would have cron run periodically as we will later describe.)
  3. Now that you have just run Cron, an email should be sent out to all of the email accounts of the users that you subscribed earlier. The email may not be beautifully formatted. Later on you can use templates to determine the emails' appearance.
  4. TROUBLESHOOTING: Did the emails not arrive? Check very carefully over your configurations of the mailhandler email box, Mail Comment, notifications, and messaging. Did you have success with the optional test of mailhandler that we described above? Also, ensure that the test users you created have the correct email addresses set. Also look at the various permissions changes that we have made, and closely check that they were all done correctly.
  5. Go to one of the test users' email accounts, open the email that was sent from the portal, and hit Reply. Type a sentence or two as a reply, and hit send.
  6. Run Cron.
  7. Now that Cron has run, it should have:
  • taken the reply that you just wrote, posted it into the Discussion Forum, attributed to the user that wrote it (this is made possible by recognizing the email address that sent the reply and matching it up with the user account in the portal -- if the "From" email address specified in the email sent in to the portal does not exactly correspond to a site account, Mail Comment should send an error email back and refuse to post the message.)
  • sent this newly posted reply back out to the subscribed participants.
  • Carry out a test conversation among the various participants, replying to the thread via email and then running Cron in between each posting. Then go and view how these posts appear in the online forum itself. Take note of how Mail Comment is varyingly successful at trimming the reply thread off of postings sent in by the various email clients. You can also go to administer > Mail Comment and choose to turn on the "email cleaner" feature, which makes some of the email-trimming better (but may not function well in some circumstances.)
  • Altering message templates

    You will probably want to modify the way that the emails are formatted, to suit the type of content and site you are working with:

    1. Go to Administer > Message templates.
    2. You will see that there are different templates for node creation, node updates, and node comments. The forum that we have just created makes heavy use of Node Comments template, but it also makes use of the Node Creation template when a new forum topic is created.
    3. Click Notifications for Node Comments. Open the four sections (Subject, Content, Digest Line) and you will see the areas where you can specify the text and spacing around the content elements that are mailed (which are specified with codes in square brackets.) In the Available Tokens section, you can see the full list of other bits of content that you can drop into the template to customize the emails' appearance.

    Configuring cron to run automatically

    1. How you configure your cron to run at your chosen frequency (every minute, every five minutes, every hour, etc) depends on where you application is running. If your Drupal portal is running on a hosting server that offers you a "control panel" interface, you may find an entry called "Cron jobs" that allows you to easily specify the commands you want to be run, at what interval. If so, the command on my host to run the cronjob is: wget -O - -q -t 1;;
    2. If you aren't able to understand setting up Cron yourself, talk to the person or company that administers your server.
    3. When Cron is running automatically on a cyclical basis, then each cron run will fully process incoming and outgoing emails to your Mail Comment-enabled forums.

    Caveats and issues with this tutorial

    Please check the watchdog table and the mail messages for errors:

    watchdog email to sender solution
    Received an email without signed parameters The email you sent was rejected because there was a signature error.
    Received an email with a expired signature The email you sent was rejected because it was sent after the allowed response time for the original email.
    Received an e-mail without a valid user id The email you sent was rejected because we couldn't authenticate it.
    Received an email with no parameters The email you sent was rejected because there was a validation error. - mailbox not set to 'mailcomment default'

    Looking for support? Visit the forums, or join #drupal-support in IRC.


    petednz’s picture

    this looks like really excellent documentation - couple of missing bits on MailContent which will inevitably cause people to scratch their heads - the "Reply Text" and for example people may want to modify this to eg "Reply above here to just add a comment, or remove this line if you want to quote some or all of the original email/post.

    Also the "Passthru to mailhandler module: " doesn't get mentioned.

    peter davis : fuzion : connect.campaign.communicate :

    NoahPollock’s picture

    Thanks for the great tutorial. I'm stuck at step five. Connection with email works fine, but nothing is posted. Instead, I get these messages:

    warning: Invalid argument supplied for foreach() in /home/wothd/public_html/modules/mailcomment/mailcomment.module on line 669.

    In log,
    Received an email with no parameters ....

    ryank76’s picture

    It doesn't seem to matter which email address I use for which account, including /user/1 - posts are always made with the author Anonymous,

    "make sure that the email address that you send the story in from is indeed set as the email address of the admin's portal account."

    What is the 'admin's portal account'? I've never heard that terminology with Drupal before.

    crystaldawn’s picture

    It should be noted that this does NOT work. It is very buggy and an incomplete set of instructions. Once all of these steps have been completed you will be left with a non-working solution that is suppose to be similar to a listserv in many ways. Its better to just use a listserv instead and modify it to suit your needs than it is to try to get this nightmare working. If you try to reply to a post via email (like you would with a listserv anyways), it will create the node, however it will NOT link it to a forum because it doesnt have any handling for taxonomies or forum db tables what so ever. So while the post doesnt show up in the forums, you will notice that it shows up in the content list (with the correct content type of 'forum') but it will not have any taxonomies set nor will the forum db tables have any info on which topics it belongs to, etc. I believe this is because mailcomment is just that. For comments only, not for forums.

    donquixote’s picture

    3. In your Drupal portal, go to Administer > Mailhandler.
    4. Click Add Mailbox.

    This does not work. You find the "Add Mailbox" link under "Content > Mailhandler mailboxes", not under "Settings".

    tryitonce’s picture

    I have followed this tutorial to the point of mail templates and so far it all worked for me as described.

    I will need to do more testing - but so far - I don't understand all the "not working" - comments.

    To me, this looks like a well written guide and I highly appreciate all the time, try-and-errors, testing and doing-it-again that went into this - thanks a million .........

    Good luck .....
    ... more recent results of trying Drupal just once are -

    tallsimon’s picture

    Thank you very much for this.

    The only bit which was omitted (I imagine this has been added since this documentation) is the pass through mailhandler bit.

    For me this is what worked:

    Mailhandler Mailbox settings (admin/content/mailhandler/edit/1)
    Message authentication method: MailComment Default

    Mailcomment settings (admin/messaging/mailcomment)
    Passthru to mailhandler module: Off
    Use default mailhandler authentication during passthru: MailComment Default
    Enable Message Cleaner: On

    nmcclain’s picture

    This worked for me too - I had to use the beta version of mailcomment to get it working right with Open Atrium, and I struggled with "Received an email with no parameters" errors until I go the message authentication settings right as shown here.


    Hanno’s picture

    This was the missing piece for me as well: be sure to go to your mailhandler mailboxes and set Message authentication method for that mailbox to 'MailComment Default'


    tryitonce’s picture

    I have tried to change the cutting-off text line - ((( Reply ABOVE this LINE to POST a COMMENT ))) according to popular demand of users.
    But it didn't work.
    The line is in file "mailcomment.module" under /www/sites/all/modules/mailcomment/mailcomment.module.
    It seems not possible to change this.
    I tried to change the line on the settings page and all 3 entries in the mailcomment.module file - but it did not work.
    When I inserted identical advice lines what to do - like this
    ((( Click REPLY & add your COMMENT ABOVE this LINE - it will be added automatically )))
    the module would no longer cut-off the text below it.

    Any advice???? - thanks .....

    Good luck .....
    ... more recent results of trying Drupal just once are -

    Vanbladi’s picture

    I read that if the string between ((( ))) gets too long, then the cut-off will not work anymore.

    tryitonce’s picture

    ... I guess so plus the line is actually in the module - so you would have to change it there I assume.

    I tried changing the line a few times and always came back to the original one - even similar short once didn't work.

    I guess you can add additional instructions in the email text that is sent out to the users on the list.

    Good luck .....
    ... more recent results of trying Drupal just once are -

    tryitonce’s picture

    Reply to Comment changes the author to the author of the comment not the one replying.

    user-alpha writes a comment. The comment is mailed (notified) to all subscribed users.
    user-beta replies to the comment and now this reply is credited to user-alpha and not to the originator - user-beta.

    Why would that be? Any ideas ......

    Good luck .....
    ... more recent results of trying Drupal just once are -