My form on my page sends the email to me but the message does not send.
There are 3 fields: Name, Email, Message
When I get an email after the user submits the form, Name and Email shows in the from field, but
The body of the email does not display the Message.
Any suggestions on how I can fix this.
The Form
Code: Select all
<form id="contact_form" method="post" action="<?php echo $target_url; ?>">
<p>
<input id="your_name" name="your_name" type="text" title="<?php _e( 'Name', THEMEDOMAIN ); ?>*" style="width:94%"/>
</p>
<p style="margin-top:20px">
<input id="email" name="email" type="text" title="<?php _e( 'Email', THEMEDOMAIN ); ?>*" style="width:94%"/>
</p>
<p style="margin-top:20px">
<textarea id="message" name="message" style="width:94%" title="<?php _e( 'Message', THEMEDOMAIN ); ?>*"></textarea>
</p>
<p style="margin-top:30px"><br/>
<input type="submit" value="<?php _e( 'Send Message', THEMEDOMAIN ); ?>"/>
</p>
</form>The form processing script, which is on the same page
Code: Select all
/*
|--------------------------------------------------------------------------
| Mailer module
|--------------------------------------------------------------------------
|
| These module are used when sending email from contact form
|
*/
//Get your email address
$contact_email = get_option('pp_contact_email');
//Enter your email address, email from contact form will send to this addresss. Please enter inside quotes ('myemail@email.com')
define('DEST_EMAIL', $contact_email);
//Change email subject to something more meaningful
define('SUBJECT_EMAIL', __( 'Email from contact form', THEMEDOMAIN ));
//Thankyou message when message sent
define('THANKYOU_MESSAGE', __( 'Thank you! We will get back to you as soon as possible', THEMEDOMAIN ));
//Error message when message can't send
define('ERROR_MESSAGE', __( 'Oops! something went wrong, please try to submit later.', THEMEDOMAIN ));
/*
|
| Begin sending mail
|
*/
$from_name = $_GET['your_name'];
$from_email = $_GET['email'];
$mime_boundary_1 = md5(time());
$mime_boundary_2 = "1_".$mime_boundary_1;
$mail_sent = false;
# Common Headers
$headers = "";
$headers .= 'From: '.$from_name.'<'.$from_email.'>'.PHP_EOL;
$headers .= 'Reply-To: '.$from_name.'<'.$from_email.'>'.PHP_EOL;
$headers .= 'Return-Path: '.$from_name.'<'.$from_email.'>'.PHP_EOL; // these two to set reply address
$headers .= "Message-ID: <".$now."webmaster@".$_SERVER['SERVER_NAME'].">";
$headers .= "X-Mailer: PHP v".phpversion().PHP_EOL; // These two to help avoid spam-filters
# Boundry for marking the split & Multitype Headers
$headers .= 'MIME-Version: 1.0'.PHP_EOL;
$headers .= "Content-Type: multipart/mixed;".PHP_EOL;
$headers .= " boundary=\"".$mime_boundary_1."\"".PHP_EOL;
$message = 'Name: '.$from_name.PHP_EOL;
$message.= 'Email: '.$from_email.PHP_EOL.PHP_EOL;
$message.= 'Message: '.PHP_EOL.$_GET['message'];
if(!empty($from_name) && !empty($from_email) && !empty($message))
{
mail(DEST_EMAIL, SUBJECT_EMAIL, $message, $headers);
echo THANKYOU_MESSAGE;
exit;
}
else
{
echo ERROR_MESSAGE;
exit;
}
/*
|
| End sending mail
|
*/