How to send the mail from php form

Hi

all

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.

<?php
if(isset($_REQUEST[‘Submit’]))
{
$first=$_REQUEST[‘fname’];
$companyname=$_REQUEST[‘cname’];
$addres=$_REQUEST[‘address’];
$cityname=$_REQUEST[‘city’];
$statename=$_REQUEST[‘state’];
$number=$_REQUEST[‘mob’];
$alternate=$_REQUEST[‘mob1’];
$email=$_REQUEST[‘email’];
$messageuu=$_REQUEST[‘subject’];
$subject=“Contact Details”;
$header = “From:'”.$first.“'”;
$subject1=“Auto Reply”;
$header1 = “From: ‘http://www.redchillies.com’”;
$message="Hi ,
\

Thank You  \

\

	 	http://www.redchillies.com";
	mail($email,$subject1,$message,$header1);
$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.'\


";
if(mail(‘samiuddin.adse@gmail.com’,$subject,$messagebody,$header))
{
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

MD.Samiuddin

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: website@redchillies.com\\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