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?
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'] = 'firstname.lastname@example.org'; $EMailFormDefaultSender = 'email@example.com'; $EnableEMailFormUTF8 = false;
This gives the markup
emailform:Pm which creates a mailform that will send electronic mail to
firstname.lastname@example.org. If the sender leaves the "sender address" field empty, the mail will appear to come from
- The sender from which the mail is sent if the 'Your address' field in the form was left empty.
- An array containing the relation of names and email-addresses (e.g.
$EMailFormAddresses['nils'] = 'email@example.com'will let you use
mailform:nilsin a WikiPage to send a mail to 'firstname.lastname@example.org')
Optional variables for customizing the look and functionality of the form
- The HTML code for the form itself. '$1' is replaced with the To:-address identifier.
- Text to be prepended to the sender's message.
- Text to be appended to the sender's message.
- 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...'.
- 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:'
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.
- Rename to emailform.php and completely get rid of mailform.php
- Ability to specify mail encoding in config.php
- Add better captcha functionality
|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 |
|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|
- 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
See discussion at EMailForm-Talk