"field_label") $form_fields = array( "element0" => 'お名前:', "element1" => 'Eメール:', "element2" => '件名:', "element3" => 'メッセージ :' ); $required_fields = array("element0", "element1", "element2", "element3"); $mail_from_name = "element0"; $mail_from_email = "element1"; $mail_subject = "element2"; //uses the email address defined above as the from email. $send_from_users_email = false; //sets the PHP setting 'sendmail_from' for use on a windows server. $windows_server = false; // Set up the error and success messages. $message_success = 'メールが送信されました。'; $message_unset_fields = "*印のある項目は必須です。"; //////////////////////////////////////////////////// // End variables to be written out by RapidWeaver // //////////////////////////////////////////////////// // Check key variable from form against session key. if ( ! isset($_POST['form_token']) || $_POST['form_token'] !== $_SESSION['security_token']) { // Set a fixed error message if the keys don't match. redirect($return_url, 'We cannot verify that you are trying to send an email from this form. Please try again.'); } // SPAM checking. If the "comment" form field has been filled out, // send back to form asking to remove content and exit the script. if ($_POST['comment']) { redirect($return_url, 'Please remove content from the last textarea before submitting the form again. This is to protect against SPAM abuse.'); } ///////////////////////// // PROCESS FORM FIELDS // ///////////////////////// $magic_quotes = (bool) get_magic_quotes_gpc(); foreach ($_POST['form'] as $key => $value) { if ($magic_quotes) { $value = stripslashes($value); } $_SESSION['form'][$key] = $value; } /////////////////////////// // CHECK REQUIRED FIELDS // /////////////////////////// //if any of the required fields are empty if (check_required_fields($required_fields) === false) { //return to form with error message. redirect($return_url, $message_unset_fields); } else { /////////////////////////////////// // ALL IS OK, SETUP GLOBAL VAR'S // /////////////////////////////////// //check email address if ( ! check_email($email)) unset($email); //set mime boundry. Needed to send the email. Mixed seperates text from attachments. $mixed_mime_boundary = 'rms-mix-x'.md5(mt_rand()).'x'; //alt seperates html from plain text. $alt_mime_boundary = 'rms-alt-x'.md5(mt_rand()).'x'; //set the from address if user supplied email is invalid use form owners. $submitted_email = ''; if (isset($_SESSION['form'][$mail_from_email])) { $submitted_email = $_SESSION['form'][$mail_from_email]; } if (check_email($submitted_email) && $send_from_users_email === false) { $from = $reply_to = $_SESSION['form'][$mail_from_name].' <'.$submitted_email.'>'; } else { $from = '<'.$email.'>'; $reply_to = check_email($submitted_email) ? '<'.$submitted_email.'>' : $from; } //set the email subject $subject = ''; if (isset($_SESSION['form'][$mail_subject])) { $subject = $_SESSION['form'][$mail_subject]; } //email headers if ($windows_server === true) { $headers = "From: $from\r\n" . "Reply-to: $reply_to\r\n" . "MIME-Version: 1.0\r\nContent-Type: multipart/mixed; " . "boundary=$mixed_mime_boundary"; } else { $headers = "From: $from\n" . "Reply-to: $reply_to\n" . "MIME-Version: 1.0\nContent-Type: multipart/mixed; " . "boundary=$mixed_mime_boundary"; } //////////////////////////// // CONSTRUCT HTML CONTENT // //////////////////////////// //Construct HTML email content, looping through each form element //Note: When you get to a file attachment you need to use $_FILES['form_element']['name'] //This will just output the name of the file. The files will actually be attached at the end of the message. //Set a variable for the message content $html_content = "\n
\n\n";
////////////////////////////
// CONSTRUCT TEXT CONTENT //
////////////////////////////
//construct a plain text version of the email.
$text_content = '';
//build a message from the reply for both HTML and text in one loop.
foreach ($form_fields as $field => $label) {
$html_content .= '' . safe_escape_string($label) . ' ';
$text_content .= "$label ";
if (isset($_FILES[$field])) {
$string = (isset($_FILES[$field]['name'])) ? $_FILES[$field]['name'] : '';
} else {
$string = (isset($_SESSION['form'][$field])) ? $_SESSION['form'][$field] : '';
}
$html_content .= nl2br(safe_escape_string($string)) . "
\n";
$text_content .= "$string\n\n";
}
//close the HTML content.
$html_content .= "