I hope you will bear with me as I am trying to create my first PHP page and I'm not having a lot of success.

I am trying to create a fairly standard form mail page to send email from a webpage. I have probably downloaded up to around 30 different scripts and I cannot get any of them to work even when tried on different servers.

In desperation, I tried to learn a little bit of PHP to try and understand the code and I 'think' it looks okay. I know that the HTML form that calls the script is fine and I also know that the script is running since I have added a few lines of code so that it displays all of the fields which should be sent in the email but I'm not receiving anything !!

I'm not sure if sendmail_path needs to be sent. According to the information I receive when I run a page with phpinfo(), the following mail settings apply:

sendmail_from me@localhost.com me@localhost.com
sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i

Do I need to set the sendmail_path and if so what format do I use (i.e. is it in '' or in "" etc.

I really would appreciate any help but I would ask you to be as clear as possible as I had never even looked at PHP code before this week and I probably wouldn't understand 99% of a technical answer.

I've posted the code below, the email addresses have been removed but otherwise it is unchanged:

$name = $_POST['name'];
$company = $_POST['company'];
$telephone = $_POST['telephone'];
$email = $_POST['email'];
$message = $_POST['message'];
$error_msg = "";
$msg = "";
$msg .= "Name: \t $name \n";
$msg .= "Company: \t $company \n";
$msg .= "Phone: \t $phone \n";
$msg .= "Email: \t $email \n";
$msg .= "Message: \t $message \n";
if($name == ""){
if($email == ""){
$mailheaders = "MIME-Version: 1.0\r\n";
$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$mailheaders .= "From: $sender_name <$sender_email>\r\n";
$mailheaders .= "Reply-To: $sender_email <$sender_email>\r\n"; 
mail("emailremoved@emailremoved.com","Testing",stripslashes($msg), $mailheaders);
<p>You have sent the following information:</p>
<table width="98%" border="0" cellspacing="1" cellpadding="1">
<td width="24%"><span class="style3">Name</span></td>
<td width="76%"><span class="style1"><?php echo $_POST['name']; ?></span></td>
<td><span class="style3">Company</span></td>
<td><span class="style1"><?php echo $_POST['company']; ?></span></td>
<td><span class="style3">Email</span></td>
<td><span class="style1"><?php echo $_POST['email']; ?></span></td>
<td><span class="style3">Telephone Number</span></td>
<td><span class="style1"><?php echo $_POST['telephone']; ?></span></td>
<td><span class="style3">Message</span></td>
<td><span class="style1"><?php echo $_POST['message']; ?></span></td>


sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i

you should have the path to sendmail only once.

Ex: /usr/sbin/sendmail -t
or: /usr/bin/sendmail -t

If you have a windows server, then you have to use SMTP, sent this in php.ini also.

If you have an MTA like qmail (its common) then use a path like:


A quick update on the situation:
After just about pulling my hair out (what I've got left anyway), I tried the simplest scripts on several hosts and they all failed - the one thing that they have in common is that register_globals is set to off.
I tried it on a host with register_globals set to on and lo and behold after four days of trying - I sent an email !!
I don't want to jump to conclsuions but at the moment I am working on the theory that this is the problem. As I am unable to alter the value of register_globals, I now need to try and work out how to alter the script so that it will work with register_globals set to off . . .