HowTo: Integrate mailing lists with forums using Listhandler and Mailhandler

Last modified: August 25, 2008 - 16:55

To allow users to post to, and receive email from Drupal forums.

  1. Listhandler works best with an already working mailing list. Please set one up and ensure that it is working. Do note that setting one up is outside the scope of this document.
  2. Listhandler requires Mailhandler to be installed and configured first.
    Both modules can be downloaded from the drupal.org website: http://drupal.org/project/mailhandler and http://drupal.org/project/listhandler If you have not, please download them and extract the contents of the archives into your modules directory.
  3. Within your Drupal website, enable the Mailhandler and Listhandler modules in Administer > Site building > Modules.
    N.B. Please enable Mailhandler first, otherwise Listhandler will fail to enable cleanly.
    In the same section, please ensure that the Forum and Comment modules are also enabled.
  4. Create a forum that you wish to be the repository for your list's messages. Administer > Content management > Forums > Add forum Enter a name, description and set the Parent (leave as "<root>" if unsure) and click on "Submit".
    In the listing, click on the forum name you just created. Make a note of the URL you are sent to. The number at the end of the URL is the 'TID' (Topic IDentification). You will need this later.
  5. Configure a mailbox
    Within your Drupal website go to Administer > Content management > Mailhandler Click on "Add mailbox"
    In the form presented, set the values as indicated:
    • E-mail address
      Email address subscribed to mailing list. This should be the address associated with the mailbox configured below, e.g. my-subscribed-mailbox@example.com
    • Second email address:
      Email address of the mailing list, e.g. my-mailing-list-address@example.com
    • Folder:
      This is the folder for my-subscribed-mailbox@example.com
      Set this to "INBOX" (without the quotes) unless another value is more suitable for your environment.
    • POP3 or IMAP Mailbox:
      This is the protocol used to connect to my-subscribed-mailbox@example.com
      Pick which ever suits your environment. Choose POP3 if unsure.
    • Mailbox domain:
      This is the full name of the email server containing my-subscribed-mailbox@example.com
      Talk to your service provider if you are unsure.
    • Mailbox port:
      Set this to 110 for POP3 or 143 if using IMAP.
      Other port numbers can be used depending on your mailserver configuration.
    • Mailbox username:
      This is the username for the my-subscribed-mailbox@example.com mailbox
    • Mailbox password:
      This is the password for the my-subscribed-mailbox@example.com mailbox
      Please note that this is stored as plain text. Please don't use something sensitive.
    • Extra commands:
      Leave blank unless you run into problems.
      A common value is "/notls", without the quotes.
    • Mime preference:
      Set this to: HTML
    • Security:
      Set this to: Disabled
    • Send error replies:
      Set this to: Disabled
    • From header:
      Set this to a common header always present in emails sent by your mailing list software.
    • Default commands:
      Enter the following two lines:
      tid: 123
      status: 1
      Where 123 is the numeric taxonomy id of the forum you created in step 4.
      The line "status: 1" sets the created node/comment as published
    • Signature separator:
      Set this to "-- ", without the quotes.
      (Yes, there is a space at the end)
    • Delete messages after they are processed?
      Check this option
    • Cron processing:
      Set this to: Enabled
    • Input format:
      (Click on "Import format:" to expand the section)
      Leave the default as "Filtered HTML", unless you have another preference
  6. Repeat steps 4 to 5 for each forum/mailing list you wish to configure.
  7. Configure permissions
    Within your Drupal website, allow authenticated users to post to forums: Administer > Roles
    Against "authenticated user", click on "edit permissions"
    Under "Forum module", check "create forum topics" and "edit own forum
    topics"
    Click on "Save permissions" (at the bottom of the page)
  8. Configure Listhandler
    Within your Drupal website go to Administer > Content management > Listhandler

    In the form presented, set the values as indicated:
    • Admin address:
      This is the email address used by Drupal to send forum posts made by anonymous users to mailing lists. Set this to "anonymous@example.com" or similar and subscribe it to your mailing lists. Set this user to not receive posts or otherwise it might be unsubscribed.
    • Strip title:
      Vales to be stripped from email subject lines, before posting them as forum
      topics/comments. Make sure to include any mailing list prefixes, like "[my-
      list]". Separate multiple values with commas.
    • Account status:
      When mailing list users post, Listhandler creates an account for them on your Drupal site. You can configure these account to be Blocked or Allowed when created.
      Set as "Allowed" if you want those people to be able to log on to your Drupal site. Set as "Blocked" if you don't.
    • Attachments as link:
      Send attachments as links instead of MIME attachments. It affects only mails generated by forum posts.
      N.B. You will need to have the Upload module enabled and allow users to attach files to forum posts
    • Mailing list and Prefix
      For each mailing list configured, you can set the [prefix] title that the mailing list software appends to the subject line of each email. Set it here to help Listhandler pick the right forum that posts should go to.
      It is also recommended that you set "Strip title" to include mailing list prefix as well.
  9. For each configured mailbox, subscribe it to the appropriate mailing list.

More info about the 'commands'

adixon - May 26, 2006 - 21:16

I've just used this successfully on a 4.6 install, and have three helpful updates, all related to step 2.B.7, the command entries for the mailhandler.

1. You have to put
type: forum
in your commands, or it'll default to creating a blog entry.

2. A warning about those command entries - you have to leave a space after the : or it won't parse properly.

3. If you want this to go into a organic group related forum, you can add
og_group: [<nid>]
to the command entries (where nid is the nid of your og_group - you can find it by looking at the url for creating nodes inside your group). Don't forget those square brackets, because og_group is required to be an array.

Other than that, it seems to be working well, thanks.

Alternative for Drupal 5+ Sympa

adixon - December 13, 2007 - 18:35

If you're using Drupal 4.7 or above, this recipe will likely not work, because the pieces aren't all being maintained. If you use Sympa as your mailing list engine, and are using Drupal 5 or above, then please try out the "Mailing List Groups" module here:

http://drupal.org/project/og2mlm

E-Mail Address in Mailhandler

juerg - March 22, 2008 - 19:37

For users of control panels like e.g. CONFIXX the first field in the setup for mailhandler (E-mail Address) can be a little bit confusing. You should enter the name of the mailbox followed by @example.com. Example:

If you set up a mailbox "web58p7" with the Email-address "mailinglist-example@example.com", you need to fill in "web58p7@example.com" in the field "E-mail address" of mailhandler.

It might also be that you have to add the command "/notls" in the field "Extra Commands" to make mailhandler working properly.

Otherwise you are likely to get the following error message: imap_open(): Couldn't open stream ...

Enter commands in *plain text*

sjtout - July 23, 2009 - 20:41

Just a quick note -- it should be obvious but I spent some time troubleshooting before realizing that because FCKEditor was already installed, I was entering the commands as HTML, so they didn't work. With FCKEditor, I just added the Mailhandler path to the list of exclusions on the FCKEditor configuration page, then returned to the edit mailbox page and re-entered the commands.

 
 

Drupal is a registered trademark of Dries Buytaert.