MailForm
<< Line Breaks | Cookbook-V1 | Reverse Headings >>
Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.
looks like this doesn't work yet in PmWiki 2
19 November 2004
Goal
This lets people contact you without the pain of giving away your email address to spam-bots. It allows you to place a small web form on a wiki page that sends email to a fixed email address.
Solution
Use Attach:mailform.php.txt and include it to your config.php. It adds the markup-command mailform:xxx. xxx is a name that you can associate with an email-address in your config.php
Example for config.php
include('mailform.php');
$MailFormAddresses['nils']='nils@dummkopf.de';
$MailFormDefaultSender = 'mailform@dummkopf.de';
This will give you the markup mailform:nils
which will create a mailform that sends mails to nils@dummkopf.de
. If the sender leaves the sender address-field emtpy, the mail will be sent from mailform@dummkopf.de
Required variables
- $MailFormDefaultSender
- The sender from which the mail is sent if the 'Your address' field in the form was left empty.
- $MailFormAddresses
- An array containing the relation of names and email-addresses (e.g.
$MailFormAddresses['nils'] = 'nils@dummkopf.de'
will let you usemailform:nils
in a WikiPage to send a mail to 'nils@dummkopf.de')
Optional: Assign values to any of these variables to customize the look of the form.
- $MailFormMsg['success']
- The message displayed after sending the mail (default: "Message has been sent successfully!")
- $MailFormMsg['failure']
- The message displayed after failing to send. (default: "Message could not be sent!")
- $MailFormMsg['error']
- The message displayed on an error. At the moment this means that the receiver-address is empty. (default: "An error occurred")
- $MailFormString
- Contains replacements for the string contained in $MailFormFmt. Each xxx in $MailFormFmt will be substituted by $MailFormString['xxx'] in the standard $MailFormFmt, the variables Your Address, Subject, Message, Send are in use. ackString is automatically replaced by the appropriate message from $MailFormMsg.
- $MailFormHeader
- A string that is prepended to the mail text. (default: "")
- A string that is appended to the mail text. (default: "\n-------------------------------------------\n"."This message was sent by the PmWiki MailForm at "."$ScriptUrl")
- $MailFormFmt
- The HTML code of the template. I don't write it down here. Use the source, Luke. If you change it, don't forget the hidden fields and the variables $ackString and $1.
Extensions
- Append senders IP Address into the mail
Add the following line to config.php
$MailFormFooter="\n-------------------------------------------\n"
."This message was sent by the PmWiki MailForm at "
.$ScriptUrl." from the IP-Address "
.$_SERVER['REMOTE_ADDR'];
See Also
History
29.2.2004 | First version |
29.2.2004 | A few bug fixes |
29.2.2004 | Changed $MailFormTemplate to $MailFormFmt, |
Added some i18n support with the $MailFormString[] array | |
1.3.2004 | Bugfix: Insertion of target name in form was missing |
Use local variable for formatting to enable multiple forms per page (not tested) | |
16.5.2004 | Changed regex to mailform:(\w+) in order to allow mailform:nils%comment% to be processed correctly as mailform:nils |
Comments & Bugs
I don't like the template for the form yet. It uses tables and no CSS. If anyone feels like redoing it, feel free.
Attach:mailform-JC.php
I've adjusted it to use definition lists and made it 508/WCAG compliant. I use it on [(approve links)
edit
diff]. --[(approve links)
edit
diff]
Very nifty! A breeze to install and works like a charm. Thanks! Oneida
Contributors
Copyright
GPL pmwiki-2.3.38 -- Last modified by {{simon}}