action
script sendemail
action="%SCRIPTURL{sendemail}%/%WEB%/%TOPIC%"
name="to"
cc
, subject
, body
, template
, redirectto
, successsection
and errorsection
from
field may be used but defaults to the address of the current user.
%SENDEMAIL%
anywhere on the page where the feedback should appear. feedbackSuccess
and feedbackError
. Default feedback messages are set below in Plugin Settings.
redirectto
is an url to redirect to a different landing page after the mail has been sent.
successsection
parameter optionally sets the named section to be extracted.
errorsection
parameter specifies the named section to be extracted when an error occured.
template
parameter to it. The default template is stored in the sendemail.tmpl
file: From: %FROM% To: %TO% CC: %CC% Subject: %SUBJECT% %BODY%The tags
%FROM%
, %TO%
, %CC%
, %SUBJECT%
and %BODY%
are replaced with the respective url parameter when the email is created.
ALLOWMAILTO
, DENYMAILTO
, ALLOWMAILFROM
, DENYMAILFROM
, ALLOWMAILCC
and DENYMAILCC
. Each can be a list of comma separated regular expressions that emails are checked against before allowing the mail to be send. This is needed to prevent this plugin from being used as an open email relay and potentially being missused to create spam emails. By default, this plugin will prohibit any email to be send. You will have to change the settings below to match your needs. Preferably, keep the settings as they are as a security measure and enable sending emails on a per-form basis by setting the respective topic preferences in the topic holding the send-email form. For example, to allow the email form on the current topic to be send to the support, use the following settings * Set ALLOWMAILTO = support * Set DENYMAILTO = * Set DENYMAILFROM =
From
, To
and CC
parameters can be either an email address or a wiki user name, in which case the email address of that wiki user is used instead.
<form enctype="application/x-www-form-urlencoded" name="mailform" action="%SCRIPTURL{sendemail}%/%WEB%/%TOPIC%" method="POST"> <input type="hidden" name="successsection" value="thanks" /> <fieldset> <legend><b>Send Email</b></legend> <div class="twikiFormSteps"> <div class="twikiFormStep"> <h3>To:</h3> <input class="twikiInputField" id="to" name="to" size="30" type="text" value="%URLPARAM{"to"}%" /> </div> <div class="twikiFormStep"> <h3>CC:</h3> <input type="text" class="twikiInputField" id="cc" name="cc" size="30" value="%URLPARAM{"cc"}%" /> </div> <div class="twikiFormStep"> <h3>Subject:</h3> <input type="text" class="twikiInputField" id="subject" name="subject" size="70" value="%URLPARAM{"subject"}%" /> </div> <div class="twikiFormStep"> <h3>Message:</h3> <textarea class="twikiInputField" cols="70" name="body" rows="6" style="width:100%">%URLPARAM{"body"}%</textarea> </div> <div class="twikiFormStep"> <input type="submit" class="twikiSubmit" value="Send" /> </div> </div> </fieldset> </form> %SENDEMAIL% <!-- %STARTSECTION{"thanks"}% ---+ Notification %SENDEMAIL% <input type="button" value="Ok" class="twikiButton" onclick="window.location.href='%URLPARAM{"origurl" default="%SCRIPTURLPATH{view}%/%BASEWEB%/%BASETOPIC%"}%'" /> %ENDSECTION{"thanks"}% -->
%STARTFORM{ name="mailForm" action="%SCRIPTURL{sendemail}%/%WEB%/%TOPIC%" method="POST" onSubmit="return checkPasswords(this)" }% <fieldset style="border:1px solid #ddd; padding:1em"> <legend><b>Send Email</b></legend> %RED%*%ENDCOLOR% All fields are required. %FORMELEMENT{ name="To" type="hidden" title="To:" default="me@myurl.com" }% %FORMELEMENT{ name="Subject" type="hidden" default="Account Request" }% %FORMELEMENT{ name="Name" type="text" mandatory="on" title="Name (First and Last):" }% %FORMELEMENT{ name="Email" type="text" mandatory="on" validate="email" title="E-mail Address:" }% %FORMELEMENT{ name="Password" type="password" mandatory="on" title="Password (caps sensitive):" }% %FORMELEMENT{ name="Confirm" type="password" mandatory="on" title="Confirm your password:" }% %FORMELEMENT{ name="body" type="textarea" rows="10" cols="80" cssclass="twikiHidden" default="$Name $Email $Company $Password $Confirm" }% %FORMELEMENT{ type="submit" buttonlabel="Send" }% </fieldset> %ENDFORM% %SENDEMAIL{feedbackSuccess="Request sent, we'll contact you shortly." feedbackError="Could not send your message, please contact us." }% <script type="text/javascript"> //<![CDATA[ function checkPasswords(inForm) { if(inForm.Password.value != inForm.Confirm.value) { alert('Your passwords do not match. Please try again.'); return false; } return true; } //]]> </script>
Title
and Summary
and want to post the values of these fields in the body of the e-mail, eiter: <input type="hidden" name="body" value="Title: %FORMFIELD{"Title"}%, Summary: %FORMFIELD{"Summary"}%" />
<textarea name="body" class="twikiHidden" cols="80" rows="6"> Title: %FORMFIELD{"Title"}% Summary: %FORMFIELD{"Summary"}% </textarea>
data/debug.txt
) Class name | Note |
---|---|
sendEmailPluginNotification |
Used for feedback after sending a mail |
sendEmailPluginError |
Styles sendEmailPluginNotification in case of an error |
SendEmailPlugin.zip
in your twiki installation directory. Content: File: | Description: |
---|---|
bin/sendemail | CGI script for TWiki 4 |
bin/sendemail-5 | CGI script for TWiki 5 |
templates/sendemail.tmpl | Email template |
data/TWiki/SendEmailPlugin.txt | Documentation |
lib/TWiki/Plugins/SendEmailPlugin.pm | Plugin stub |
lib/TWiki/Plugins/SendEmailPlugin/Core.pm | Plugin core |
pub/TWiki/SendEmailPlugin/sendemailplugin.css | CSS styles |
LocalSite.cfg
: $TWiki::cfg{SwitchBoard}{sendemail} = ['TWiki::Plugins::SendEmailPlugin::Core', 'sendEmail', {sendemail => 1}];and redirect all calls to
sendemail
to sendemail-5
in your apache configuration.
Plugin Author: | TWiki:Main.ArthurClemens |
Copyright: | © 2007 Arthur Clemens; 2008 Michael Daum |
License: | GPL (GNU General Public License) |
Plugin Version: | 1.2.2, 17 Oct 2008 |
Change History: | |
17 Oct 2008 | 1.2.1 TWiki:Main/MichaelDaum: added support for TWiki-5; fixed sending emails to login names |
26 Jun 2008 | 1.2.0 TWiki:Main/MichaelDaum: added ALLOW/DENY preference settings to prevent this plugin from being used as an open spam relay; added template option allowing more control over email header etc; fixed mod_perl/perperl coding errors; sender address is the current user, it will default to the wikimaster's only as a last resort; allow user names in addition to plain email addresses in From, To and Cc; allow multiple users in To and Cc; added a redirectto , successsection and errorsection options to land on a different feedback page; reorganized code for lazy compilation |
16 may 2007 | 1.1.3 TWiki:Main/ArthurClemens: fixed bug in bin script that caused form query data to get emptied. |
15 may 2007 | 1.1.2 TWiki:Main/ArthurClemens: improved error notifications. |
13 May 2007 | 1.1.1 TWiki:Main/ArthurClemens: changed sendmail script invocation to be called through bin script sendemail ; added CSS styles for feedback notification; fixed typo 'feedbackSucces'. |
05 May 2007 | 1.0 First release. |
TWiki Dependency: | $TWiki::Plugins::VERSION 1.1 |
CPAN Dependencies: | none |
Other Dependencies: | none |
Perl Version: | 5.005 |
Benchmarks: | GoodStyle nn%, FormattedSearch nn%, SendEmailPlugin nn% |
Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/SendEmailPlugin |
Feedback: | http://TWiki.org/cgi-bin/view/Plugins/SendEmailPluginDev |
Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/SendEmailPluginAppraisal |