Scribble Designs: Web Design in Northern Ireland.

Configuring The Contact Form Module In Drupal

By Gerard McGarry on 3rd September 2007, filed in Drupal. You can leave a response below. Tags: , ,

I’m currently wrapping up on a Drupal installation for a client I’ve been working with for a while. One of the finishing touches on the new site is a contact form. Thankfully, Drupal has a contact form module built in, so there’s not really much work to do to get it up and running.

Here are some notes on configuring the Contact Form module for Drupal:

Activate The Module!

That’s right, browse to Administer / Site Building / Modules in your site and activate the Contact module. Save the configuration and you’re ready to go.

Configure The Contact Form

Browse to Administer / Site Building / Contact Form to begin. Click the link at the top of the page to Add Category.

  • Give the category a name. I’ve used “Contact Site” (where site is the name of the website).
  • Configure recipients. You can put in a single email address here, or multiple addresses separated with a comma. I’m using info@domain.com.
  • If you like, you can configure a polite autoresponder to send an acknowledgement back to the visitor.
  • Take note of the weight setting – if you have more than one category in your contact form, you’ll have to set the weight so that the fields are ordered in the right manner.
  • Since we have only one category, we’ll ignore the Selected setting for now.

When you’re done configuring, click Submit to create the contact form category.

This basic setup with give you a form with fields for name, email address, subject and message. There’s also a check box that allows the sender to receive a copy of the message.

Configuring Contact Form Settings

You can customize the contact form message text by browsing to Administer / Site Building / Contact Form / Settings. This page also allows you to set maximum messages per hour – an anti-spam setting that prevents you getting bombarded with contact form spam!

You can also allow members to have a personal contact form which relays emails to the address they have in their profile.

Integrating Into Site Navigation

When you activate the Contact Form module, a menu item gets created for the page (which points to yoursite.com/contact. This item is disabled by default, so you have to enable it and move it to the desired place in your navigation.

To do this, browse to Administer / Site Building / Menus. Find the Contact Form link and click the enable button. The edit form should appear.

You can change the title of the contact form if desired, but the important items are the Parent Item field and the Weight. Set these according to your navigation structure and you should notice the link appearing when you refresh the page. You might have to fiddle with the weight of the item to get it in the right position.

Testing The Form

You’re nearly finished. Just don’t forget to test the form by sending a quick message through it!

[tags]Drupal, Tips, Web Design[/tags]

24 Responses to “Configuring The Contact Form Module In Drupal”

  1. Dave Cooper said on September 7th, 2007 at 2:47 am :

    Hi! Here’s a question from sunny Toronto…(it really is hot and sunny here today, for some reason)

    I have a client who needs an “volunteer application” form that sends an email and an auto-responder, just like a contact form.

    But it’s a complex form, with every possible type of field, and a two-column layout. It looks like the Contact module isn’t designed for this sort of thing. Should I get into the forms api?

    Thanks in advance for your help!

  2. Dave Cooper said on September 7th, 2007 at 2:49 am :

    just stumbled across this — maybe that’s the answer?

    http://drupal.org/project/webform

  3. Gerard McGarry said on September 7th, 2007 at 7:58 pm :

    Hi Dave

    I haven’t had a requirement for anything more complicated in a contact form. It does look like the WebForm module might give a bit more flexible.

    Looking at the admin interface for the contact form module, it seems you can have different categories of form. Might be worth looking at this in a test Drupal setup.

    Hope this helps.

  4. Justin said on September 13th, 2007 at 3:30 am :

    Hi Gerard!

    Do you know offhand if one can use the Contact Form module to create multiple, different forms on a site? For instance, I might want one form that’s a generic Contact Us-type form with a given set of fields in one area, and a Advertise With Us form in another with different fields.

    Thanks,

    Justin

  5. Gerard McGarry said on September 13th, 2007 at 6:54 am :

    Hi Justin

    Contact form categories might be a way to go – I set them up on my test Drupal installation and what they do is give one generic form, but you have a drop-down menu to select the topic of your enquiry – General/Sales/Support, etc.

    You can use a different email address for each category, so your sales category might send a message to the sales department while a support request would go to the appropriate person(s) in your support department.

    I think the Webform module Dave suggested above might have a bit more flexibility in that each form can be created as a seperate node. I haven’t tested it though.

    Hope that helps! Loving Nerdliness by the way, you’re doing a great job over there.

    Gerard

  6. tim said on September 27th, 2007 at 4:17 am :

    we recently created some quite specific contact forms for a custom drupal site, and we didnt end up using any of the drupal modules to do it at all. the custome one was used for a basic site feedback form only
    check them out at http://www.tramanco.com.au – links on paratransit, chekway and spare parts pages

  7. tim said on September 27th, 2007 at 4:19 am :

    oh and a quick question – are you keen to share your code for the awesoome little button links under your post?
    be much appreciated :)
    Cheers

  8. Ain said on November 30th, 2008 at 12:59 am :

    The issue is, the whole form is private and shown only for authenticated users…

  9. Ain said on November 30th, 2008 at 1:08 am :

    What this article does not discuss is setting the Access rules in User management in order to enable the contact form for public use. For further info, please see the YouTube tutorial at Drupal Dude.

  10. Stanford said on December 14th, 2008 at 10:17 pm :

    I’m using Drupal 6. I am waiting for privatemsg to become stable. I was thinking that for now I could just have a contact form on user profiles as a temporary solution to not having privatemsg. Is there any way to make the recipient email address dynamic? So each user has a “Contact Me” form on their profile. Thanks.

  11. Gerard McGarry said on December 29th, 2008 at 7:29 pm :

    I think what you’re talking about is per-user contact forms – I think those are configurable in the contact module, plus you may have to dip into the permissions to set this up properly.

  12. Mark Conroy said on January 7th, 2009 at 2:53 pm :

    You might also have a look at the Contact Forms module – that is Contact Forms Module, not Contact Form Module. It makes a separate contact form for each category on your contact form, so if you have categories such as: sales, news, manager, marketing, etc. then you can have a link to their contact pages looking like: http://www.markconroy.net/contact/sales and http://www.markconroy.net/contact/news etc. It’s quite cool.

    Besides that, WebForms seems to be what you need.

  13. Mark Conroy said on January 7th, 2009 at 2:57 pm :

    I’ve asked this on the Drupal Forums but got no response. Could you tell me if there is a limit to the amount of email addresses that one can add to a category on a contact form in Drupal? Or if there is a limit to the amount of characters that can be added.

    I have one contact form with 166 email addresses, but I have a feeling that it is being sent to only about 75 of them.

    Thanks for the help,
    Mark Conroy.

  14. Mark Conroy said on January 18th, 2009 at 9:02 am :

    I’ve just discovered the problem here myself. It’s a mailserver issue because of shared hosting.

    Mark.

  15. Zoe Blessing said on January 23rd, 2009 at 1:59 am :

    This is a great tutorial on how to configure the Contact module. Problem is, my site building page mysteriously has no references to the Contact module! On the module page it is listed and enabled, however when I go to the Site Building page, there’s no Contact link there! I clicked around and it isn’t anywhere. I am stumped. BTW I’m using Drupal 6.9. What could cause the configuration page to go missing? Emptying the cache doesn’t do anything either. It’s so weird.

  16. Gerard McGarry said on January 23rd, 2009 at 1:01 pm :

    Have you enabled the Contact module in build/modules?

  17. Zoe Blessing said on January 23rd, 2009 at 4:55 pm :

    I did! Multiple times! The checkbox is there and enabled. I even tried unchecking it, saving it, then going back and rechecking the box and saving it again… still no contact link to be found anywhere in Site Building. It makes no sense. I may just have to try installing a different contact module altogether.

  18. Mark Conroy said on January 25th, 2009 at 6:31 pm :

    Have you tried reinstalling the contact module?

  19. aj said on February 22nd, 2009 at 3:06 pm :

    The contact form module is so basic, I can’t help but wonder why there isn’t more functionality built-in. Like, oh, for example, the ability to build custom contact forms, a basic requirement for 95% of websites. Ok I exaggerated, maybe not 95%, but still. The features of contact module and webform module should be merged together.

  20. Alicia said on March 11th, 2009 at 4:36 pm :

    I’m having an issue with the contact module. The automatic response sends a lot of code with the message at the bottom, and there is no way that I can see to send it in plain text. Also, if someone copies and paste formatted text into the contact form, I get an e-mail that says “n/a” and nothing else. Is this possibly something wrong with my text editor?

  21. Mark Conroy said on March 14th, 2009 at 7:02 pm :

    The forms sends the html, but not as a webpage so it looks like html on the reader’s side. You should turn off your text editor for the contact form.

    That worked for me.

  22. B.C. said on July 20th, 2009 at 3:50 am :

    I’ve enabled the contact form and in the menu, the Contact Form link only appears in the menu when I’m logged in…not when I’m just visiting without being logged in.

  23. Gerard McGarry said on July 20th, 2009 at 10:17 am :

    You need to go to your user permissions and allow anonymous users to see the contact form – have a look down the list of permissions and you’ll see what I mean.

  24. Arnaud said on August 19th, 2009 at 3:28 pm :

    B.C., very right as far as “Personal” contact form is concerned. Anonymous users can access the sitewide contact form but not the Personal contact form you might have attached to User profiles. Too bad, I would need it as well. That won’t change for D6, code freeze, I understand. Looking into PrivateMsg’s permissions.

    -arnaud

Leave a Reply