No recipient addresses found in header [closed]
I got this error while sending a mail using PHP mail function
Error Is:- No recipient addresses found in header
Please help me out
Here is the code
//my code starts from here
$to = navruk@gmail.com;
$subject = $_POST['txtsub'];
$messgae = $_POST['txtmessage'];
$signature = $_POST['txtsignature'];
$redirect = "thanks.php";
$error = "error.php";
$body ="<table width='700' align='center' cellpadding='0' cellspacing='0' border='0'>
<tr>
<td valign='top'>
$messgae <br>
</td>
</tr>
<tr>
<td valign='top'>
$signature <br>
</td>
</tr>
</table>";
$from = "Aakrutisolutions<info@aakrutisolutions.com>";
$headers = "From: $from\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= "Content-type: text/html;charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
$headers .= "X-Mailer: Just My Server\r\n";
$headers .= "".$body."\n";
if(mail($to, $subject, $message, $headers))
{
?>
<script language="javascript">
location.href='bulkmail.php?sts=mailsent';
</script>
<?php
}
else
{
?>
<script language="javascript">
location.href='bulkmail.php?sts=mailnotsent';
</script>
<?php
}
//My code ends here
Your
$to = navruk@gmail.com;
assignment needs quotes:
$to = "navruk@gmail.com";
I can understand the sarcasm in the comments, never the less, I don't think it is okay to behave like that, even if the answer is obvious. It is very easy to find the information:
$headers = 'From: Navruk <navruk@gmail.com>' . "\r\n" .
'To: Navruk1 <navruk@gmail.com>, Navruk2 <navruk@gmail.com>' . "\r\n" .
'Cc: Navruk3 <navruk@gmail.com>' . "\r\n" .
'Bcc: Navruk4 <navruk@gmail.com>' . "\r\n" .
'Reply-To: noreply@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail(
"navruk@gmail.com",
"How to do basic mailing",
"I can easily GOOGLE and find this LINK at the top http://php.net/manual/en/function.mail.php. Surprisingly, it is the PHP manual. If I CLICK this link I will find not only how to use the PHP command mail, but also a bunch of examples! This took me about 10 seconds to find.",
$headers
);
I suggest you read the message and try it yourself, can you beat my 10 seconds?!?
精彩评论