PHP contact form submitting but not receiving email - php

I realise this question has been asked numerous times before but everyone's code is obviously different and I am quite new to php so just looking to see if someone can give me some help.
I have created a basic contact form for a site but for some reason the information is not being sent to my email address although I believe that the form is submitted?
my PHP code is:
<?php
session_start();
//$to_mail = "architects#palavin.com,t.lavin#palavin.com,12yorkcourt#gmail.com";
$to_mail = "danny#enhance.ie";
//$cc="paul#enhance.ie";
$mail_sent = 0;
if(isset($_POST['submit'])){
//echo "the form was submitted";
$error= array();
$name = trim(strip_tags($_POST['name']));
if($name == "")
$error['name'] = 1;
$email = trim(strip_tags($_POST['email']));
if($email == "")
$error['email'] = 1;
$phone = trim(strip_tags($_POST['phone']));
$address = trim(strip_tags($_POST['address']));
$description = trim(strip_tags($_POST['description']));
$str = trim(strip_tags($_POST['secu']));
if ( isset($_SESSION['code_']) && $_SESSION['code_'] == strtoupper($str)){} else {$error['secu'] = 1;}
if(empty($error)){
$headers = 'From: "Euro Insulation" <no-reply#euroinsulations.ie>'."\r\n";
//$headers .= 'CC: "'.$cc.'" <'.$cc.'>'."\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "";
$subject = "New contact message";
$message = "New Contact message, received from: <br /> \n ";
$message .= "<b>Name</b> ".$name."<br /> \n";
$message .= "<b>Email</b> ".$email."<br /> \n";
$message .= "<b>Phone</b> ".$phone."<br /> \n";
$message .= "<b>Address</b> ".$address."<br /> \n";
$message .= "<b>Description</b> ".$description."<br /> \n";
if(#mail($to_mail,$subject,$message,$headers ))
{
echo "mail sent";
$mail_sent = 1;
}
else echo "mail not sent";
}
}
?>
my html form looks like this:
<table width="100%" border="0" cellspacing="0" cellpadding="10">
<tr>
<td width="65%" valign="top"><p class="header"><br>
Contact US <br>
</p>
<?php if($mail_sent==1){
print "Thank you for your message.";
} else { ?>
<form class="email_sub" method="post" >
<table width="77%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td><label for="name" class="formtext" <?php if($error['name']==1) echo "style='color:red;'" ?> >Name:</label></td>
<td><input type="text" name="name" id="text" <?php if($name) echo "value='".$name."'" ?> /></td>
</tr>
<tr>
<td><label for="phone" class="formtext">Number:</label></td>
<td><input type="text" name="phone" id="phone"/><tr>
<br />
<tr>
<td><label for="email" class="textarea" <?php if($error['email']==1) echo "style='color:red;'" ?>>Email:</label></td>
<td><input type="text" name="email" id="email" <?php if($email) echo "value='".$email."'" ?> /></td>
</tr>
<tr>
<td><br /></td>
</tr>
<tr><td><label for="address" class="textarea">Address/Location of project:</label></td>
<td><textarea rows="3" cols="20" name="address" id="address" style="width: 400px;"><?php if($address!="") echo $address ?></textarea></td>
</tr>
<tr>
<td><br /></td>
</tr>
<br />
<tr>
<td><label for="description" class="fixedwidth">Enquiry</label></td>
<td><textarea rows="3" cols="20" name="description" id="description" style="width: 400px;"><?php if($description!="") echo $description; ?></textarea></td>
<tr>
<td><br /></td>
</tr>
<!-- form -->
<tr>
<td><label> </label></td>
<td><input type="submit" value="Submit" name="submit" /></td>
</tr>
</table>
</form>
<?php } ?>
Am i missing something obvious here?? Any help will really be appreciated thanks!

You have used sessions which is not required here, you can also use flag variable instead of arrays in this simple form, use this updated code.
<?php
//$to_mail = "architects#palavin.com,t.lavin#palavin.com,12yorkcourt#gmail.com";
$to_mail = "danny#enhance.ie";
//$cc="paul#enhance.ie";
$mail_sent = 0;
if(isset($_POST['submit'])){
//echo "the form was submitted";
$name = trim(strip_tags($_POST['name']));
if($name == "")
$error = true;
$email = trim(strip_tags($_POST['email']));
if($email == "")
$error = true;
$phone = trim(strip_tags($_POST['phone']));
$address = trim(strip_tags($_POST['address']));
$description = trim(strip_tags($_POST['description']));
if($error != true){
$headers = 'From: "Euro Insulation" <no-reply#euroinsulations.ie>'."\r\n";
//$headers .= 'CC: "'.$cc.'" <'.$cc.'>'."\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "";
$subject = "New contact message";
$message = "New Contact message, received from: <br /> \n ";
$message .= "<b>Name</b> ".$name."<br /> \n";
$message .= "<b>Email</b> ".$email."<br /> \n";
$message .= "<b>Phone</b> ".$phone."<br /> \n";
$message .= "<b>Address</b> ".$address."<br /> \n";
$message .= "<b>Description</b> ".$description."<br /> \n";
if(#mail($to_mail,$subject,$message,$headers))
{
echo "mail sent";
$mail_sent = 1;
}
else echo "mail not sent";
} else {
echo 'validation error';
}
}
?>
You have also missed out the else statement for your form validation test so no errors getting displayed when you submit form.

Remove the at sign from mail function and see what errors your get. #mail suppresses errors from being displayed.

Comment out the following line: if ( isset($SESSION['code']) && $SESSION['code'] == strtoupper($str)){} else {$error['secu'] = 1;}
You should be able to reach the mail function.

Related

Add Password to Form

I'm trying to create a form where the user is required to use a password that I give them.
So when the user submits a form they will have to type "Password123" into the form before they can submit the form to my email. However, if they get the password wrong, the site will redirect to an error page.
So far, I keep getting an internal server error.
Here is the html:
<form method="post" action="contactengine.php">
<div class="forms">
<h4>PASWORD: <input type="password" placeholder="******" name="Password" /></h4>
<h4>YOUR NAME: <input type="text" placeholder="Smith Family" name="Name" /></h4>
<h4>YOUR CITY: <input type="text" placeholder="Anytown, USA"name="City" /></h4>
<h4>YOUR TELLEPHONE: <input type="text" placeholder="123.456.7891"name="Tel" /></h4>
<h4>YOUR EMAIL: <input type="text" placeholder="you#emaildomain.com" name="Email" /></h4>
<h4>MESSAGE TO US:</h4> <textarea width="10000px" name="Message" placeholder="Go ahead and say something nice to us!" rows="20" cols="20" id="Message"></textarea>
<br>
<input type="submit" name="submit" value="Submit" class="submit-button" />
</form>
</div>
This is the PHP:
<?php
$Password = Trim(stripslashes($_POST['Password']));
$EmailFrom = "me#gmail.com";
$EmailTo = "me#gmail.com";
$Subject = "THIS IS THE SUBJECT";
$Name = Trim(stripslashes($_POST['Name']));
$Tel = Trim(stripslashes($_POST['Tel']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
// THIS IS WHERE I AM STUCK
if ($Password != "Password123") {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
May be you can try this ...
if ($Password != "Password123") {
echo "<script language='javascript'> window.location='error.htm'; </script>";
exit;
}
if ($Password != "Password123") {
echo "<script>document.location.href='new.php'</script>";
}
You may try this code,May be helpful to you.

Uploading an image from contact form and send as email attachement

I am trying to add a new field in the contact us form field, but I am stumped on how to properly do this. I simply need to have the uploaded file be sent as an attachment of the contact us email. Thanks in advance Rahul
Here is my PHP code:
<?php
$submitted = FALSE;
if ($_POST['contact_form']) {
$submitted = TRUE; // The form has been submitted and everything is ok so far…
$name = htmlspecialchars($_POST['name'], ENT_QUOTES);
$email = htmlspecialchars($_POST['email'], ENT_QUOTES);
$country = htmlspecialchars($_POST['country'], ENT_QUOTES);
$message = htmlspecialchars($_POST['message'], ENT_QUOTES);
if ($name == "") {
// if the name is blank… give error notice.
echo "<p>Please enter your name.</p>";
$submitted = FALSE; // Set this to FALSE so that it the message is not sent.
}
if ($email == "") {
// if the email is blank… give error notice.
echo "<p>Please enter your e-mail address so that we can reply to you.</p>";
$submitted = FALSE; // Set this to FALSE so that it the message is not sent.
}
if ($country == "") {
// if the country is blank… give error notice.
echo "<p>Please enter your country.</p>";
$submitted = FALSE; // Set this to FALSE so that it the message is not sent.
}
if ($message == "") {
// if the message is blank… give error notice.
echo "<p>Please enter a question.</p>";
$submitted = FALSE; // Set this to FALSE so that it the message is not sent.
}
if ($_POST['email'] != "" && (!strstr($_POST['email'],"#") || !strstr($_POST['email'],".")))
{
// if the string does not contain "#" OR the string does not contain "." then…
// supply a different error notice.
echo "<p>Please enter a valid e-mail address.</p>";
$submitted = FALSE; // Set this to FALSE so that it the message is not sent.
}
$problemIn = '';
$ip = $_SERVER['REMOTE_ADDR'];
$url = (!empty($_SERVER['HTTPS']))
? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']
: "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$to = "rahul#test.com"; // Set the target email address.
$header = "From: $email";
$attention = "Someone has sent you question from your webpage!";
$message = "Name: $name \n Country: $country \n Question: $message \n IP Address: $ip \n Link: $url \n";
if ($submitted == TRUE)
{
mail($to, $attention, $message, $header);
echo '<script type="text/javascript">alert("Thank you. Your question has been sent.");</script>';
}
}
?>
Here is my HTML code:
<form method="post" name="frmmail" id="frmmail" action="<?php echo $_SERVER['SCRIPT_NAME'] ?>" onSubmit="javascript: return validation();" eenctype="multipart/form-data">
<input name="name" id="txtname" value="" placeholder="Name" onfocus="if(this.value == 'Name')" class="usericon" />
<input name="email" id="txtmail" value="" placeholder="Email" onfocus="if(this.value == 'Email')" class="emailicon" />
<input name="country" id="txtcountry" value="" placeholder="Country" onfocus="if(this.value == 'Country')" style="margin:0" class="countryicon" />
<textarea name="message" id="txtmsg" placeholder="Your Comment/Question" onfocus="if(this.value == 'Your Question')" class="msgicon"></textarea>
<input type="file" name="file" class="file" />
<input type="submit" value="Submit" class="button" />
<input type="hidden" name="contact_form" value="submitted" />
</form>
Here is HTML Form
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Attachment Without Upload - Excellent Web World</title>
<style>
body{ font-family:Arial, Helvetica, sans-serif; font-size:13px;}
th{ background:#999999; text-align:right; vertical-align:top;}
input{ width:181px;}
</style>
</head>
<body>
<form action="emailSend.php" method="post" name="mainform" enctype="multipart/form-data">
<table width="500" border="0" cellpadding="5" cellspacing="5">
<tr>
<th>Your Name</th>
<td><input name="fieldFormName" type="text"></td>
</tr>
<tr>
<tr>
<th>Your Email</th>
<td><input name="fieldFormEmail" type="text"></td>
</tr>
<tr>
<th>To Email</th>
<td><input name="toEmail" type="text"></td>
</tr>
<tr>
<th>Subject</th>
<td><input name="fieldSubject" type="text" id="fieldSubject"></td>
</tr>
<tr>
<th>Comments</th>
<td><textarea name="fieldDescription" cols="20" rows="4" id="fieldDescription"></textarea></td>
</tr>
<tr>
<th>Attach Your File</th>
<td><input name="attachment" type="file"></td>
</tr>
<tr>
<td colspan="2" style="text-align:center;"><input type="submit" name="Submit" value="Send"><input type="reset" name="Reset" value="Reset"></td>
</tr>
</table>
</form>
PHP Code
<?php
$to = $_POST['toEmail'];
$fromEmail = $_POST['fieldFormEmail'];
$fromName = $_POST['fieldFormName'];
$subject = $_POST['fieldSubject'];
$message = $_POST['fieldDescription'];
/* GET File Variables */
$tmpName = $_FILES['attachment']['tmp_name'];
$fileType = $_FILES['attachment']['type'];
$fileName = $_FILES['attachment']['name'];
/* Start of headers */
$headers = "From: $fromName";
if (file($tmpName)) {
/* Reading file ('rb' = read binary) */
$file = fopen($tmpName,'rb');
$data = fread($file,filesize($tmpName));
fclose($file);
/* a boundary string */
$randomVal = md5(time());
$mimeBoundary = "==Multipart_Boundary_x{$randomVal}x";
/* Header for File Attachment */
$headers .= "\nMIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed;\n" ;
$headers .= " boundary=\"{$mimeBoundary}\"";
/* Multipart Boundary above message */
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mimeBoundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
/* Encoding file data */
$data = chunk_split(base64_encode($data));
/* Adding attchment-file to message*/
$message .= "--{$mimeBoundary}\n" .
"Content-Type: {$fileType};\n" .
" name=\"{$fileName}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mimeBoundary}--\n";
}
$flgchk = mail ("$to", "$subject", "$message", "$headers");
if($flgchk){
echo "A email has been sent to: $to";
}
else{
echo "Error in Email sending";
}
?>

Failed to load resource: the server responded with a status of 405 (Method Not Allowed)

This is the error coming while i try to send mail using php.
Failed to load resource: the server responded with a status of 405 (Method Not Allowed) sendmail.php
this is the form
<form action="sendmail.php" method="post" id="contactform" >
<div id='name-error' class='error'>Please enter your name.</div>
<input name="name" placeholder="Name" class="form-control" type="text" id="name">
<div id='email-error' class='error'>Please enter your valid E-mail ID.</div>
<input name="email" placeholder="Email" class="form-control" type="text" id="email">
<div id='subject-error' class='error'>Please enter the subject.</div>
<input name="subject" placeholder="Subject" class="form-control" type="text" id="subject">
<div id='message-error' class='error'>Please enter your message.</div>
<textarea name="message" placeholder="Message" id="message" rows="4" class="form-control"></textarea>
<div id='mail-success' class='success'>Your message has been sent successfully.</div>
<div id='mail-fail' class='error'> Sorry, error occured this time sending your message.</div>
<input type="submit" value="Send Message" class="form-control" id="send-message">
</form>
this is the query
$.post("sendmail.php", $("#contactform").serialize(), function(result){
enter code here if (result == 'sent'){
$('#mail-success').slideDown(500).delay(1000).slideUp(500);
$('#send-message').removeAttr('disabled').attr('value', 'Send Message');
} else{
$('#mail-fail').slideDown(500).delay(1000).slideUp(500);
$('#send-message').removeAttr('disabled').attr('value', 'Send Message');
}
});
}
});
this is the sendmail.php file
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$from = "info#vonesoft.com";
$to = "mujtaba1004#gmail.com";
$head = "New Contact Lead - VOneSoft";
$body = "Hi , <br /><br />";
$body .= "<table border='1' cellpadding='4' cellspacing='0'>";
$body .= "<tr><td>Name </td><td> " . $name . " </td></tr>";
$body .= "<tr><td>Email </td><td> " . $email . " </td></tr>";
$body .= "<tr><td>Subject </td><td> " . $subject . " </td></tr>";
$body .= "<tr><td>Message </td><td> " . $message . " </td></tr>";
$body .= "</table>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
// More headers
$headers .= "From:" . $from "\r\n";
mail($to, $head, $body, $headers);
echo '1';
?>
You forgot to concatenate here
$headers .= "From:" . $from. "\r\n";
-------------^

contact form not sending to email cakephp

i'm new in php..i would like to sent contact form to my gmail account..
everything just going fine whrn i click the submit button,but my problem is this form not sending me the email..
this is my html code
<form action="kontact-sent" onSubmit="return validate_form(this)" method="post">
<table width="415" border="0" cellspacing="1" cellpadding="5" class="t1">
<tr>
<td align="left" valign="top" bgcolor="#efefef">First name:<br /><input name="FirstName" type="text" id="FirstName" style="width:300px;" /></td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#efefef">Email address<br /><input type="text" name="EmailAddress" id="EmailAddress" style="width:300px;" />
<input name="Email_Confirmation" class="Email_Confirmation2"/></td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#efefef">Message<br /><textarea name="Inquiry" id="Inquiry" style="width:300px; height:100px;"></textarea></td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#efefef"><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
function validate_EmailAddress(field,alerttxt){
with (field)
{
apos=value.indexOf("#");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2)
{alert(alerttxt);return false;}
else {return true;}
}
}
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{
alert(alerttxt);return false;
}
else
{
return true;
}
}
}
function validate_form(thisform)
{
with (thisform)
{
if (validate_required(FirstName,"Please enter your First Name.")==false)
{FirstName.focus();return false;}
if (validate_EmailAddress(EmailAddress,"Please enter a valid Email Address.")==false)
{EmailAddress.focus();return false;}
if (validate_Inquiry(Inquiry,"Please enter your Inquiry.")==false)
{Inquiry.focus();return false;}
}
}
this is my .php
<?php
// if the Email_Confirmation field is empty
if(isset($_POST['Email_Confirmation']) && $_POST['Email_Confirmation'] == ''){
// put your email address here scott.langley.ngfa#statefarm.com, slangleys#yahoo.com
$youremail = 'afiqrashid91#gmail.com';
// prepare a "pretty" version of the message
$body .= "Thank You for contacting us! We will get back with you soon.";
$body .= "\r\n";
$body .= "\r\n";
foreach ($_POST as $Field=>$Value) {
$body .= "$Field: $Value\r\n";
$body .= "\r\n";
}
$CCUser = $_POST['EmailAddress'];
// Use the submitters email if they supplied one
// (and it isn't trying to hack your form).
// Otherwise send from your email address.
if( $_POST['EmailAddress'] && !preg_match( "/[\r\n]/", $_POST['EmailAddress']) ) {
$headers = "From: $_POST[EmailAddress]";
} else {
$headers = "From: $youremail";
}
// finally, send the message
mail($youremail, 'Form request', $body, $headers, $CCUser );
}
// otherwise, let the spammer think that they got their message through
?>
Thank You for contacting us! We will get back with you soon.
i hope that anyone can help me..thanks in advance..
$headers = "From: $_POST[EmailAddress]";
Should be:
$headers = "From: $_POST['EmailAddress']";
Also, email messages shouldn't exceed 70 characters per line. You'll want to fix this by adding:
$body = wordwrap($body, 70);

Php email send issue

Following is my HTML Select field which gets all the emails from my database. Now I'm trying to send single or multiple emails with php. But It doesn't send any emails. Can you tell me what is wrong with my code ?
Html Code:
<tr>
<td valign="top">To</td>
<td>
<select multiple="multiple" size="7" name="to[]">
<?php
$getemail = mysql_query("SELECT email FROM clients");
while($res = mysql_fetch_array($getemail)){
$email = inputvalid($res['email']);
echo "<option value='$email'>$email</option>";
}
?>s
</select>
</td>
</tr>
Php Code:
foreach($to as $total){
$total;
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$mail = mail($total, $subject, $msg, $headers);
}
Update-Full Code:
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" />
<table width="400" border="0" cellspacing="10" cellpadding="0" style="float:left;
position:relative;">
<tr>
<td>Subject</td>
<td><input type="text" name="subject" value="<?php if(isset($_POST['subject'])) echo
$_POST['subject']; ?>" class="tr"/></td>
</tr>
<tr>
<td valign="top">Message</td>
<td><textarea name="msg" class="textarea_email"><?php if(isset($_POST['msg'])) echo
$_POST['msg']; ?></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Send Message" class=" submit" name="Submit"/></td>
</tr>
</table>
<table style="float:left; position:relative; border:0px #000 solid;" width="400" border="0"
cellspacing="10" cellpadding="0">
<tr>
<td valign="top">To</td>
<td>
<select multiple="multiple" size="7" name="to[]">
<?php
$getemail = mysql_query("SELECT email FROM clients") or die(mysql_error());;
while($res = mysql_fetch_array($getemail)){
$email = inputvalid($res['email']);
echo "<option value='$email'>$email</option>";
}
?>s
</select>
</td>
</tr>
</table>
</form>
Php code:
if(isset($_POST['Submit']) && $_POST['Submit'] == "Send Message")
{
$subject = inputvalid($_POST['subject']);
$msg = inputvalid($_POST['msg']);
$to = $_POST['to'];
if(isset($subject) && isset($msg) && isset($to)){
if(empty($subject) && empty($msg) && empty($to))
$err[] = "All filed require";
}
else{
if(empty($to))
$err[] = "Please select email address";
if(empty($subject))
$err[] = "Subject require";
if(empty($msg))
$err[] = "Message require";
}
if(!empty($err))
{
echo "<div class='error'>";
foreach($err as $er)
{
echo "<font color=red>$er.</font>
<br/>";
}
echo "</div>";
echo "<br/>";
}
else{
foreach($to as $total){
echo $total;
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$mail = mail($total, $subject, $msg,
$headers);
}
if($mail)
echo "<font color=green>Successfully sent your message. We will be get in
touch with you. Thank You.</font/><br/><br/>";
header("Refresh:10; url=email.php");
}
}
You can send multiple emails for one mail function.
Only pass email address with comma separated.
like "test#gmail.com,test1#gmail.com"
first make sure that you query is correct.
Change the following line:
$getemail = mysql_query("SELECT email FROM clients");
to
$getemail = mysql_query("SELECT email FROM clients") or die(mysql_error());
Change the following line:
$total;
to
echo $total . '<BR />';
Save and refresh the page
What is your output?
Do you get an errormessage?
Do you see emailadresses?
edit:
change the following line
$mail = mail($total, $subject, $msg, $headers);
to
if (!mail($total, $subject, $msg, $headers);) {
echo 'This is not working';
}
What is your result?
Check your apache-configs! I had the same problem on my local machine. as soon as i uploaded it on a fully configured Webserver, the code started to work! Maybe this solves your problem, too
Some time mail() function may not work so you should go with PHPMailer, for more details to use this, you can go through a good documentation :
Send mail using PHPMailer

Categories