Thank you! The page has successfully been sent.';
$MailFormSendTo = 'Send this page by email to:';
$MailFormSendFrom = 'Your email address:';
$MailFormText = 'Enter a message:';
$MailFormSubject = $WikiTitle . ' - ' . $pagename;
$MailFormDefaultText = '';
$MailFromErrorEmail = 'It appears as if your email address is invalid. Please
check the spelling of your email address and try again.';
$MailFormNoHTML = 'If your email doesn\'t support HTML, please visit the page: ';
$MailFromDisclaimer = 'This page has been sent from a mailform on ' . $WikiTitle . '.';
SDV($HandleActions['mailform'], 'HandleMailForm');
SDV($HandleMailFmt, array(&$PageStartFmt,
&$PageMailFormFmt, '$PageText',
&$PageEndFmt));
SDV($PageMailFormFmt, '
' . $MailFormTitle . '
');
function HandleMailForm($pagename) {
global $HandleMailFmt, $HandleActions, $FmtV, $MailFormTitle;
$page = RetrieveAuthPage($pagename,"read");
if (!$page) { Abort("?cannot read $pagename"); }
PCache($pagename, $page);
if (isset($page['text'])) $text=$page['text'];
else $text = FmtPageName($DefaultPageTextFmt,$pagename);
$text = '(:groupheader:)'.@$text.'(:groupfooter:)';
$FmtV['$PageText'] = MarkupToHTML($pagename,$text);
if (@$_POST['post'])
{ HandlePostMailForm($pagename); }
PrintFmt($pagename,$HandleMailFmt);
}
function HandlePostMailForm($pagename) {
global $PageMailFormFmt, $MailFormSubject, $MailFromErrorEmail, $WikiTitle,
$MailPostsFrom, $MailPostsTo, $MailFormNoHTML, $MailFormThankYou, $FmtV;
$sendfrom = @$_POST['sendfrom'];
$mailtext = @$_POST['mailtext'];
// Validate the send from address
if (!ereg("^([a-zA-Z0-9_-]|\\-|\\.)+@(([a-zA-Z0-9]|\\-)+\\.)+[a-z]{2,4}\$", $sendfrom)) {
$error_html .= $MailFromErrorEmail . '
';
$PageMailFormFmt = $error_html . $PageMailFormFmt;
return;
}
// Replace all semi-colons with commas, explode the sendto parameter on commas,
// validate each piece, and mail.
$sendto = $_POST['sendto'];
$sendto = str_replace(';', ',', $sendto);
$sendto = explode(',', $sendto);
$pagelink = FmtPageName('$PageUrl', $pagename);
$PageMailFormFmt = $MailFormThankYou;
// Message
$mailtext = htmlspecialchars($mailtext, ENT_NOQUOTES);
$message = nl2br(stripslashes($mailtext)) . "
" ;
$message .= $MailFormNoHTML . '' . $pagelink .
'
';
$message .= $FmtV['$PageText'];
$message .="
$MailFromDisclaimer";
// Subject
$subject = $_POST['sendsubject'];
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
// Additional headers
// $headers .= "From: $WikiTitle <$sendfrom>\n";
$headers .= "From: <$sendfrom>\n";
$headers .= "Bcc: $MailPostsTo\n";
while (list($key, $val) = each($sendto)) {
$val = trim($val);
if (!ereg("^([a-zA-Z0-9_-]|\\-|\\.)+@(([a-zA-Z0-9]|\\-)+\\.)+[a-z]{2,4}\$", $val)) {
$error = 1;
$error_html .= $val . ' appears to be invalid. This page was
not sent to this email address.
';
} else {
// Recipients
$to = $val;
// Mail it
mail($to, $subject, $message, $headers);
}
}
if ($error == 1) {
$PageMailFormFmt .= '
' . $error_html;
}
if ($_POST['chkSendSelf'] == true) {
mail($sendfrom, $subject, $message, $headers);
}
$PageMailFormFmt .= '
';
}
?>