function.mail

the mail() function

Moderators: macek, egami, gesf

Post Reply
BlueChrome
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Aug 29, 2009 8:52 am

function.mail

Post by BlueChrome » Sat Aug 29, 2009 8:57 am

I was actually looking for help with the mail function in php, I think there may be a setting in my php.ini file or windows that is not letting my mail go through. When I submit my mail form, I get no errors but the CSS on the form becomes messed up and a link appears at the top saying 'function.mail'. When I hover over the link, it's to a page in my root directory called 'function.mail' (I don't have a page called 'function.mail'). Any idea what could be wrong? Here's my code...

Code: Select all

<?php 
// set flag to indicate whether mail has been sent
$mailSent = false;
if (array_key_exists('wrComments', $_POST)) {
	// mail processing script
	// remove escape characters from POST array
if (get_magic_quotes_gpc()) {
  function stripslashes_deep($value) {
    $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
    return $value;
    }
  $_POST = array_map('stripslashes_deep', $_POST);
  }
  	// validate the input, beginning with name
	$name = trim($_POST['name']);
	if (empty($name)) {
		$error['name'] = 'Please enter your name';
		}
	$email  = $_POST['email'];
	// check for valid email address
$pattern = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
if (!preg_match($pattern, trim($email))) {
  $error['email'] = 'Please enter a valid email address';
  }  
  	// check the content of the text area
	$messageBody = trim($_POST['message']);
	if (empty($messageBody)) {
		$error['message'] = 'Please enter a message';
		}
	// initialize variables
	$to = 'myemail@earthlink.net';
	$subject = 'Feedback from Website';
	// build the message
	$message = 'On '.date('l, M j, Y').' at '.date('g:ia').', ';
	$message .= "$name ($email) wrote: \n\n";
	$message .= $messageBody;
	// send the email if there are no errors
	if (!isset($error)) {
		$mailSent = mail($to, $subject, $message);
		// check that the mail was sent successfully
		if (!mailSent) {
			$error['notSent'] = 'Sorry, there was a problem sending your mail. Please try later.';
			}
		}
	}
?>

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests