php 在标题中找不到收件人地址
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4744133/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No recipient addresses found in header
提问by Navruk
I got this error while sending a mail using PHP mail function
使用 PHP 邮件功能发送邮件时出现此错误
Error Is:- No recipient addresses found in header
错误是:- 在标题中找不到收件人地址
Please help me out
请帮帮我
Here is the code
这是代码
//my code starts from here
//我的代码从这里开始
$to = [email protected];
$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<[email protected]>";
$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
//我的代码到此结束
回答by Max Kielland
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 <[email protected]>' . "\r\n" .
'To: Navruk1 <[email protected]>, Navruk2 <[email protected]>' . "\r\n" .
'Cc: Navruk3 <[email protected]>' . "\r\n" .
'Bcc: Navruk4 <[email protected]>' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail(
"[email protected]",
"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?!?
建议你看帖子自己试试,能不能打我10秒?!?

