EMailForm
Questions answered by this recipe
- Can I create a form that will allow people to contact me via mail without giving my email address away to spammers?
- Can this form send data using UTF-8 encoding?
- Can it have some captcha functionality?
Description
The emailform.zipΔ script allows you to place a small web form into a wiki page that sends email to fixed email addresses. It can be modified to send e-mails using utf-8 encoding, and to use a simple but effective SPAM protection. Moreover it can be styled using css and produces xhtml valid code.
Installation and Configuration
To use the recipe, simply unpack it into the directory containing your pmwiki installation. The emailform.php file should go into the cookbook directory, the other files should go into pub/emailform/. The script adds a emailform:xyz
markup to your wiki pages. The xyz
is a name that you can then associate with an email address in your local customization file (e.g. local/config.php). For example:
$EnableEMailFormSecurity = true; include_once('cookbook/emailform.php'); $EMailFormAddresses['Pm'] = 'pmichaud@pobox.com'; $EMailFormDefaultSender = 'wiki@example.com'; $EnableEMailFormUTF8 = false;
This gives the markup emailform:Pm
which creates a mailform that will send electronic mail to pmichaud@pobox.com
. If the sender leaves the "sender address" field empty, the mail will appear to come from wiki@example.com
.
Notes
Required variables
- $EMailFormDefaultSender
- The sender from which the mail is sent if the 'Your address' field in the form was left empty.
- $EMailFormAddresses
- An array containing the relation of names and email-addresses (e.g.
$EMailFormAddresses['nils'] = 'nils@dummkopf.de'
will let you usemailform:nils
in a WikiPage to send a mail to 'nils@dummkopf.de')
Optional variables for customizing the look and functionality of the form
- $EMailFormFmt
- The HTML code for the form itself. '$1' is replaced with the To:-address identifier.
- $EMailFormHeader
- Text to be prepended to the sender's message.
- Text to be appended to the sender's message.
- $EnableEMailFormSecurity
- If this is set to 'true' the user will be asked to enter a three-digit code before sending. This variable should be set before the line starting with 'include_once...'.
- $EnableEMailFormUTF8
- If this is set to 'true' emails will be sent using utf-8 encoding. This variable should be set after the line starting with 'include_once...'.
Other strings are all internationalized - the default values belong in the 'en' (English) language:
$XL['en']['MFsuccess'] = 'Message has been sent successfully.'; $XL['en']['MFfailure'] = 'Message could not be sent.'; $XL['en']['MFerror'] = 'An error has occurred.'; $XL['en']['MFwrongcode'] = 'Wrong security code. Are you sure you are human?'; $XL['en']['Your address:'] = 'From:'; --noe - to be complete ... is it : $XL['en']['Your Address:'] = 'Your Address:'; $XL['en']['Subject:'] = 'Subject:'; $XL['en']['Message:'] = 'Message:'; $XL['en']['Send'] = 'Send'; -- and even... $XL['en']['Repeat Security Code:'] = 'Repeat Security Code:'
CSS styling
The form can be styled using css. To alter the look of the emailform, simply edit the emailform.css
file that should be located in the folder pub/emailform/
of your pmwiki installation.
Older Stuff
The mailform.phpΔ script allows you to place a small web form into a wiki page that sends email to fixed email addresses. It can be modified to send e-mails using utf-8 encoding, and to use a simple but effective SPAM protection. Moreover it can be tyle using css and produces xhml valid code. Mailform.php wont be supported for releases later than v 1.5. The emailform-s.phpΔ script adds a 3-digit confirmation code to reduce spam, similar to CommentBoxPlus, but without the JavaScript. It is based on emailform.php above. Formatting is a bit kludgy. Example on http://www.cricket.onebit.ca/Main/Feedback2; if the form moves, you can reach it from the site's sidebar.
The old emailform1_2.phpΔ is still available here.
Future planning
- Rename to emailform.php and completely get rid of mailform.php
- Ability to specify mail encoding in config.php
- Add better captcha functionality
Release Notes
29.02.2004 | First version |
29.02.2004 | A few bug fixes |
29.02.2004 | Changed $MailFormTemplate to $MailFormFmt, |
Added some i18n support with the $MailFormString[] array | |
01.03.2004 | Bugfix: Insertion of target name in form was missing |
Use local variable for formatting to enable multiple forms per page (not tested) | |
16.05.2004 | Changed regex to mailform:(\w+) in order to allow mailform:nils%comment% to be processed correctly as mailform:nils |
06.01.2005 | Converted for PmWiki v2 (Pm) |
08.02.2005 | Created emailform.php to work with the TellAFriend script. |
19.10.2005 | fixed a minor bug in emailform.php: emailform_2005-10-19.phpΔ |
15.12.2006 | Added confirmation code to reduce spam. emailform-s.phpΔ . Sandy |
03.08.2007 | Version 1.5 of mailform.php and emailform.php Merged xhtml, utf-8 and SPAM catcher to mailform making these obsolete. Hombre |
04.08.2007 | Version 1.5.1: Renamed flags to start with Enable, Updated comments in sourcecode. Hombre |
10.11.2007 | Version 1.5.3: Corrected a mistake in the help file. Hombre |
See Also
Contributors
- Nils Knappmeier
- Pm, 2005-01-06, revised for PmWiki v2
- Susan 2006-03-02, added config.php markup for emailform.php
- Sandy 2006-12-15, added emailform-s.php for spam prevention
- Hombre 2007-08-03, merged utf-8, SPAM catcher and xhtml to mailform.php and emailform.php 1.5
Comments
See discussion at EMailForm-Talk
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.