This is GPL, only it seems odd to include a license in a programm that has twice the size of the license. Modifications to work with PmWiki 2.0, Copyright (c) 2005 by Patrick R. Michaud Modifications to work with the MyWikiFriends.php cookbook module, anti-copyright 2005 by Jeffrey W Barke Revision 1.1 20050802 Jeffrey W Barke Changed all variables and functions to "e"mailform. Revision 1.2 20050910 Vit Rozkovec Added possibility to require email Added one function IsValidEmail - uses regular expression to check, if email is valid (if required) Added one error message for case of wrong email. */ # Set this true if you require users to fill their email # false otherwise $EMailFormRequireEmail = true; XLSDV('en', array( 'MF' => '', 'MFsuccess' => 'Message has been sent successfully.', 'MFfailure' => 'Message could not be sent.', 'MFwrongmail' => 'Your e-mail is not valid.', 'MFerror' => 'An error has occurred.')); $r = @$_REQUEST['emailform']; $EMailFormResult = FmtPageName("$[MF$r]", $pagename); # This is the default form, as a table. The '$1' is replaced with # the word that comes after the mailform: markup -- the rest are # straightforward $...Fmt substitutions. SDV($EMailFormFmt,"
\$EMailFormResult
$[Your Address:]
$[Subject:]
$[Message:]
"); # This defines the mailform: markup -- it's just a straight text # substitution. Markup('emailform', '>links', '/\\bmailform:(\\w+)/', FmtPageName($EMailFormFmt, $pagename)); # These define what happens after someone has submitted a message. # The variables are the header and footer for the email message, # while HandleMailForm sends the message according to the # value of 'address' in the request. SDV($EMailFormHeader,""); SDV($EMailFormFooter, "\n-------------------------------------------\n" ."This message was sent by the PmWiki MailForm at $ScriptUrl\n"); SDV($EMailFormDefaultSender,""); $HandleActions['emailform'] = 'HandleEMailForm'; function HandleEMailForm($pagename) { global $EMailFormAddresses, $EMailFormHeader, $EMailFormFooter, $EMailFormDefaultSender, $EMailFormRequireEmail; $to = $EMailFormAddresses[$_REQUEST['address']]; $from = $_REQUEST['sender']; $subject = $_REQUEST['subject']; $text = $EMailFormHeader.stripmagic($_REQUEST['text']).$EMailFormFooter; if($EMailFormRequireEmail) { if(!IsValidMail($from)) { $msg = 'wrongmail'; } else { if (!$to || !$_REQUEST['text']) { $msg = 'error'; } else if (mail($to, $subject, $text, "From: $from")) { $msg = 'success'; } else { $msg = 'failure'; } } } else { if (!$from) { $from=$EMailFormDefaultSender; } if (!$to || !$_REQUEST['text']) { $msg = 'error'; } else if (mail($to, $subject, $text, "From: $from")) { $msg = 'success'; } else { $msg = 'failure'; } } header("Location: $ScriptUrl?pagename=$pagename&emailform=$msg"); } # This function checks whether the email is valid or not function IsValidEMail($email) { if(ereg("^[-a-zA-Z0-9!#$%&'*+/=?^_`{|}~]+(\.[-a-zA-Z0-9!#$%&'*+/=?^_`{|}~]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$", $email)) { Return true; } else { Return false; } } ?>