What is wrong with this mail() function?

They have: 37 posts

Joined: Jun 2006

I have tried EVERYTHING. The latest version of the script I am using is below. I don't know what is wrong with it. It would send an e-mail to e.g. [email protected] , but it wouldn't send anything to [email protected] or [email protected] . I've contacted my web host about it and I was told I have to use headers and priority. I've changed the script now, so it uses headers and priority, but it keeps doing the same thing. Please, somebody send me a script that works or correct this one:

<?php
$youremail
= trim ($_POST['youremail']);
$your = htmlspecialchars ($youremail);
$mail = strip_tags ($your);
$ab = stripslashes ($mail);

$To = \"$ab\";
$Subject = \"Welcome\";
$body = \"Test mail\";
$message = wordwrap($body, 70);
$headers = \"From: [email protected]\n\";
$headers .= \"X-Priority: 3\n\";
$headers .= \"Cc: \n\";
$headers .= \"Bcc: \n\";
$headers .= \"Reply-To: \n\";
mail(
$To, $Subject, $message, $headers);
?>

Raise And Share a Million.com - Rewarding to those who like to help others

They have: 426 posts

Joined: Feb 2005

Dont know, try to concatenate using

<?php
$headers
= $headers. \" X-Priority: 3\n \";
?>

Maybe your platform is being funny?

They have: 38 posts

Joined: Nov 2006

You need to make sure the host is an smtp server. Also I noticed this with some of mine but check your spam folder and/or junk mail on those accounts mine was getting filetered out as junk.

A patch is a piece of software which replaces old bugs with new bugs.

West Chatham Homes | Custom American made Caps | Custom Handmade Knives

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

It really doesn't look like this is a problem with that script, but something with the way your hosting is setup. Do you have any other PHP apps that use mail on the server? Are they working?

a Padded Cell our articles site!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.