I want to send mail to users but when i click on submit button, the email isn't sent and I get an error that says request was not sent. here is my code,
<?php
include('submit.php');
if(isset($_POST['submit']))
{
extract($_POST);
$to = "chintan.suthar777@gmail.com";
$subject = "Email template";
$message = file_get_contents('index.php');
$headers = 'MIME-Version: 1.0'."\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
$headers .= "From: chintan.suthar777@gmail.com";
$mail_sent = mail($to, $subject, $message, $headers);
if($mail_sent)
echo "<script>alert('Thank you. we will get back to you');
window.location='index.php';exit();</script>";
else
echo "<script>alert('Sorry.Request not send');
window.location='index.php';exit();</script>";
}
?>
my HTML code is below:
<form name="news_data" action="email.php" method="post" enctype="multipart/form-data">
<table width="100%">
<tbody>
<tr>
<td><h3>News </h3></td><td><input type="text" readonly value="1" name="sec_1_new[]" id="sec_1_new_1" /></td>
</tr>
<tr>
<td>Title of news :</td>
<td><input type="text" name="sec_1_title_news[]" id="sec_1_title_news_1" /><br /><br /></td>
</tr>
<tr>
<td>Description: </td>
<td><textarea rows="5" cols="30" name="sec_1_desc[]" id="sec_1_desc_1" ></textarea><br /><br /></td>
</tr>
<tr>
<td>Title of Link :</td>
<td><input type="text" name="sec_1_newslink[]" id="sec_1_newslink_1" /><br /><br /></td>
</tr>
<tr>
<td>URL of News:</td>
<td><a href="#"><input type="text" name="sec_1_news_url[]" id="sec_1_news_1_url" /><br /><br /></a></td>
</tr>
<tr>
<td>News image:</td>
<td><input type="file" name="sec_1_news_img[][]" id="sec_1_news_1_image" ><br /><br /></td>
</tr>
<tr>
<td></td>
<td align="right"><input class="add" type="button" value="Add" id="sec_1_news_1_add" onClick="add_new(this.id)" /></td>
</tr>
</tbody>
</table>
<input type="submit" name="submit" value="Submit" />
</form>