DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:contact

Contact Form Plugin

Compatible with DokuWiki

No compatibility info given!

plugin Add a Contact Email Form to a page

Last updated on
2008-04-26
Provides
Syntax
Conflicts with
contactmodern

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to bureaucracy, bureaucracyau, conform, contactmodern, groupmail

Tagged with email, 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 auto-generated !?” )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:

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 relays… 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 JavaScript 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:

  • visible – replaces @ with [at], . with [dot] and - with [dash]
  • hex – uses hex entities to encode the address
  • none – no obfuscating is used
  • Type: String
  • Default: hex

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 useful in authenticated wiki's like the one I manage.
Thanks for your plugin.
Francisco Castanheiro fdsc [at] di [dot] fct [dot] unl [dot] 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.”


This plugin is outdated and won't work out of the box with the newer versions of DokuWiki. My version is 2009-02-14. This reason is the way of getting the settings from the conf/default.php has changed. To make it work you should edit syntax.php and change

if (isset($_REQUEST['to'])){
  $to = $conf['plugin']['contact'][$_REQUEST['to']];
}
else{
  $to = $conf['plugin']['contact']['default'];
}

to

if (isset($_REQUEST['to'])){
  // !!I didn't actually test this alternative!!
  $to = $this->getConf($_REQUEST['to']);
}
else{
  $to = $this->getConf('default');
}

I suggest the author updates this asap. This fixes the problem of the last comment.

Nathalie Casati 2009/05/21 18:25

I've updated my dokuwiki to the 2009-02-14 version (because of the security hole) and my contact plugin doesn't word anymore (same with the Nathalie Casati hack). :( — Arnaud Fouquaut 2009/06/01 23:28
~ ~ NOCACHE ~ ~ does the magic. (klem @ dokuwiki-2009-02-14b)
Yes! It perfectly works with ~~nocache~~ and 2009-02-14 version ! Thanks ! —

Help: I do not need the safety-line “ENTER HUMAN”!Which lines from the syntax i have to delete?

Go to plugins/contact/syntax.php and a) comment out ( /* .. */ ) or delete the if..verify clause (4 lines) around line 92 and b) the form field (<tr>…verify..;) around line 183. (Bernd 21.01.10)


HINT:
To get the contact-plugin working with DokuWiki-rc2009-12-02, it is necessary to use the 2 hints from Nathalie and klem. So, change the code in syntax.php and use the Option at the page where you use the contact plugin (where you insert your contact form).
Thank you all
Ronny

Nope, it's enough just to add ~~NOCACHE~~ on top of the contact page source. Works without any further hacks.
cheers,
flo

yes that works, wish I read this comment first, spent ages testing all the options
Art


Anyone been able to get 2 contact forms on the same page working? (With me, it sends 2 mails each time a user tries to use the forms) Arno

Can't download this now it has a broken link

plugin/contact.txt · Last modified: 2023-12-17 21:26 by Aleksandr

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki