I am utilizing a WordPress theme to setup an internet site for any client, and among the pages is really a contact page. The contact.php page includes the mailer module below. It really works great after i send messages from Chrome and Opera on my small mac (to some gmail address.) However, whenever I send messages (from the browser) on the PC, I recieve an e-mail having a noname attachment with no message. Can there be any apparent error using the mailer module below? I do not have lots of experience setting these up, but was wishing the one which included the theme works!
Thanks a lot.
/* -------------------------------------------------------------------------- Mailer module -------------------------------------------------------------------------- These module are utilized when delivering email from contact page */
//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
|
*/