Table of Contents

Plugin - Contact Form

contact plugin by Bob Baddeley
Add a Contact Email Form to a page

Last updated on 2008-04-26. Provides Syntax.
No compatibility info given!

Similar to bureaucracy, conform.

Tagged with contact, email, feedback, form.

I wanted to have a contact page that would allow someone to contact the author or some other responsible person, so I created this contact page. I used the usermanager plugin and the discussion plugin as help in creating this.

Download the plugin here: http://bobbaddeley.com/doku.php/projects/programming/wiki/contact

Installation instructions:

  1. Unzip the plugin and put it in your plugins folder of your wiki
  2. Add some entries in your /conf/local.php ( or better /conf/local.protected.php if there is in /conf/local.php the line : ”@include(DOKU_CONF.'local.protected.php'); → local.php is autogenerated !?” )file that look like
    $conf['contact'][PROFILE_NAME] = "blah@blah.com";

    You can have as many profiles as you want, with each one being a possible TO address. This is where the emails will be sent. You SHOULD have a $conf['contact']['default'] entry, too. This will be the default TO address if none is supplied in the parameters.

  3. To use the plugin, on any page just enter the code:
    {{contact>}}

    This will create a form with a “name”,”from address”, “subject”, and “comment” field. It will send an email to whatever the $conf['contact']['default'] value is. You can also specify the 'to' or 'subj' parameters:

    {{contact>to=PROFILE_NAME}}

    or

    {{contact>subj=Feedback from Site}}

    or join them with a | character:

    {{contact>to=PROFILE_NAME|subj=Feedback from Site}}

    When the subject is specified in the parameters, it is not a field on the contact form.

It's that easy!

In action:

http://bobbaddeley.com/doku.php/projects/programming/wiki/contact

How it works:

Basically, it uses the same mail function that the rest of the wiki uses, so it requires no extra server configuration (although you do have to add a line in your local.php to specify some TO addresses). When the form is submitted, it will post back to the same page, but set a variable so it knows to send an email. It will send an email TO the address specified and FROM that same address (so that it doesn't fail if the user enters a strange email address). I have taken some steps to make sure that it isn't vulnerable to some of the more common attacks, so it shouldn't be possible to use maliciously.

Comments:

Here is another update version. Tested on dokuwiki-2008-05-05.

  1. modify verify method
  2. support multi-language defined for javascript messages

Jonathan Tsai 2008/06/30 16:01


I've made some updates to this script that added another layer of security (it has a regular expression check to make sure their email address is valid), and also changed the captcha aspect so that the question and answer are configured through ADMIN-Plugin Configuration, so that it could be changed to whatever you prefer to use as well as change it once a bot figures it out. I've put that version on my site at http://www.evenfooting.org/contact.tar.gz which you can install with that URL right in your plugin manager.
Tested on dokuwiki-rc2008-04-11.
Mario Lurig April 25, 2008 http://www.evenfooting.org

This could be easily used for spam relais… you should hide the email address somehow.

Spam relays should be impossible now. Hiding the email address is a different problem and I'll look into it, but the solution just below seems to work well.

I've made this slight modification to contactmail.php:

 $to_profile = $_REQUEST['to'];
 $to = $conf['contact'][$to_profile];

and added the following to conf/dokuwiki.php:

// Contact form profiles
$conf['contact']['default'] = 'myaddress@blah.com';
$conf['contact']['test'] = 'anotheraddress@blahblah.org';
//........
// add as many profiles as you need
//........

Now I can use the same command syntax, but without specifying an email directly in the page:

{{contact>default}}

This solves the problem described in the previous comment.

Dec 15, 2005 - AS www.sabetta.com

Thanks for the idea. I incorporated your modification into the latest version of the plugin. — Bob Baddeley 2006-11-06 10:54

Just an fyi, the javacript function can be placed in its own file, script.js. Dokuwiki will automatically include the contents of that file in the javascript links at the top of the page. — Christopher Smith 2005-12-17 06:20

done.

mailguard

This configures if and how email addresses will be obfuscated against harvesting bots. Possible options are:

The above from mailguard is given in the config page. Can't this feature be used to obfuscate email addresses.

Daya Kiran dkdude4f at the rate of gmail dot com


Just downloaded the plugin, thanks, it saved me time writing my own. But isn't that a bug? Quoting: “if (mail_send($to, $subject, $comment, $to)){” I guess it should be: “if (mail_send($to, $subject, $comment, $email)){” You can delete this comment when the bug (if it's a bug) will be fixed. Regards, Webmaster.

It's not a bug. I intentionally did that because if the user enters a bad email address, then the email won't necessarily get sent. This way, the email is more likely to get sent. The downside is that the 'reply' button doesn't work properly, but I consider it a small sacrifice for making sure that the email gets delivered in the first place –Bob Baddeley 2006-12-10 08:23

—-

I'd like to suggest to move to the lang file the following bits of text in syntax.php: “Mail sent successfully”, “Mail not sent. Please contact the administrator” and the rest of the error messages there. Right now I had to translate them inline. (Also, I'm not sure there's such thing as JavaScript lang file for a plugin, but if it exists, then it would be nice to move there script.js error messages.) Regards, Webmaster.


I suggest to implement body option that fill <textarea></textarea> It's simple ad usefull if you want extend the form.

{{contact>to=PROFILE_NAME|subj=Feedback from Site|body=your age:   your address:  ...}}
[..] <textarea>your age:   your address:  ...</textarea>

I've made two modifications to syntax.php

$comment = $_SESSION[DOKU_COOKIE]['auth']['user']."\r\n";
 $ret .= "<tr><td>".$this->getLang("name")." : </td><td>".$_SESSION[DOKU_COOKIE]['auth']['user']."</td></tr>";

This sets the name sent in the email to the name of the logged user. It's usefull in authenticated wiki's like the one i manage.
Thanks for your plugin.
Francisco Castanheiro fdsc@di.fct.unl.pt


There was a small error on this page: The profile name showed up as PROFILEA some places, and should be PROFILE_NAME.


I have not been able to get this to work for me. I've installed it, tried all of the configurations, and sent test emails. I get a message saying the email as successfully sent. But the test emails never show up in my inbox, nor do they show up in my spam filter. I haven't figured out how to get it working.


There is a little bug in the french lang.php. To remove it, change the line :

$lContact Formang['direction']  = 'ltr';

to

$lang['direction']  = 'ltr';

I've put an updated french file here : http://arno.skamp.eu.org/download/plugin_contact_dokuwiki/lang/fr/lang.php :) — Arnaud Fouquaut 2008/06/02 00:08


Array-Bug: There is a bug that prevents the sending of mails: syntax.php asks for $conf['plugin']['contact']['default'] when only $conf['contact'][…] is defined, according to this page. I deleted the ['plugin'] parameter from all respective arrays, set the $conf['contact']['default'] parameter in conf/local.php - now my code works fine. I propose you either change the code or the documentation. Versions: Dokuwiki 2007-06-26b, contact/syntax.php dated 02.02.2008
Bernd vdB - April 2, 2008

Array-Bug: Yes, there is a disconnect between the documentation and the code. Leave syntax.php alone, and in local.php, you should specify $conf['plugin']['contact']['default'] = youraddress@yourhost.com . This is the convention used by other plugins. Versions: Dokuwiki 2008-05-05
Rick Bradford - Aug 26, 2008

:?: What can't I get this to work? I am using debian sid, exim4, and latest dokuwiki.

I can send email from CLI. I have all permissions set to 777. I installed content.zip, and configured local.php, exactly as instructed.

Every time I try to send an email, I get the error message: “Message not sent. Contact your administrator.”