使用PHP邮件功能发送邮件时出现此错误
错误是: - 在标题
中找不到收件人地址请帮帮我
这是代码
//我的代码从这里开始
$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
}
//我的代码在这里结束
答案 0 :(得分:8)
我可以理解评论中的讽刺,从来没有那么少,我认为这样做是不行的,即使答案是显而易见的。很容易找到这些信息:
$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
);
我建议你阅读邮件并自己尝试一下,你能打败我的10秒吗?!?
答案 1 :(得分:5)
你的
$to = navruk@gmail.com;
分配需要引用:
$to = "navruk@gmail.com";