How to send the mail from php form



I am trying send the mail from php. But it is not delivering the mail to the address and it is not giving any error.

$subject=“Contact Details”;
$header = “From:'”.$first.“'”;
$subject1=“Auto Reply”;
$header1 = “From: ‘’”;
$message="Hi ,

Thank You  \

$messagebody="Hi , \


	 	 First Name : '.$first.'\


		 company Name: '.$companyname.' \


		 Address: '.$addres.'\


		 City Name: '.$cityname.'\


		 State Name: '.$statename.'\


		 Mobile : '.$number.'\


		 Alternate Mobile : '.$mob1.'\


		 Email-id : '.$email.'\


		 Message: '.$messageuu.'\

print $msg=“Your Details have been sent successfully”;

else {

echo(“<p>Message delivery failed…</p>”);

I tried to find out the error. but could not find out

please help me out

Thanks & Regards


mail() doesn’t provide any errors unlike mysql_error. There is no way to determine the error apart from true or false as the result of the function.

Assuming you’re not seeing your “Mail delivery failed” message, then mail() has accepted and sent the message. What you need to do is start a process of elimination - does your server have sendmail installed? Does the target mailbox have a spam filter?

Also as several folks here will tell you, using $_REQUEST does carry some risk. If you understand what those are and have prepared for them in your processing script then you may not want to worry but if you don’t understand the risks or how to defend against them then you may want to consider using $_POST.

Your missing MIME and content type from your headers, many mail servers will reject mails with non standard or missing header parts.

Try replacing you header string for the following

   $header = "MIME-Version: 1.0\\r\
   $header .= "Content-type: text/html; charset=iso-8859-1\\r\
   $header .= "From:\\r\

You dont need the quotes around FROM data you had in your code and the code should be an email address not a website address.

If that doesnt work you can try removing the \r from the header lines, some servers dont like both CR and LF.

Yes , take note of what tango said above regarding $_REQUEST