Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么html没有显示在我使用php mail()函数发送的电子邮件中?_Php_Html_Email - Fatal编程技术网

为什么html没有显示在我使用php mail()函数发送的电子邮件中?

为什么html没有显示在我使用php mail()函数发送的电子邮件中?,php,html,email,Php,Html,Email,我使用php mail()函数发送了电子邮件确认消息,但它不处理html标记。你知道为什么吗 $content="Dear $name, <br /><br />Thank you for registering at NAME. Before we can activate your account one last step must be taken to confirm your email address ."; $content.

我使用php mail()函数发送了电子邮件确认消息,但它不处理html标记。你知道为什么吗

   $content="Dear $name, <br /><br />Thank you for registering at NAME. Before we can activate your account one last step must be taken to confirm your email address .";
            $content.="<br /><br />Please note - you must complete this last step. You will only need to visit this URL once to confirm your email address.<br /><br />To complete your registration,";
            $content.=" please visit this URL:<br /><a href='$link1' target='_blank'> $link1 </a><br /><br /><br />";
            $content.="If you are still having problems signing up please contact a member of our support staff at&nbsp;<a href='mailto:email@gmail.com'>email</a> or contact our <a href='$link2'>customer care</a>. <br /><br />";
            $content.="All the best,<br />NAME<br />";
            mail($custArray['email'],"Please Confirm Your Email",$content);
$content=“亲爱的$name,

感谢您在name注册。在我们激活您的帐户之前,必须采取最后一步来确认您的电子邮件地址。”; $content.=“

请注意-您必须完成最后一步。您只需访问此URL一次即可确认您的电子邮件地址。

即可完成注册,”; $content.=“请访问此URL:




”; $content.=“如果您在注册时仍有问题,请联系我们的支持人员或联系我们的。

”; $content.=“祝您一切顺利,
姓名
”; 邮件($custary['email'],“请确认您的电子邮件”,$content);
您可能需要为html电子邮件添加标题。以下是php网站()中的示例:

//要发送HTML邮件,必须设置内容类型头
$headers='MIME版本:1.0'。“\r\n”;
$headers.='内容类型:文本/html;字符集=iso-8859-1'。“\r\n”;
//附加标题
$headers.='To:Mary,Kelly'。“\r\n”;
$headers.=“发件人:生日提醒”。“\r\n”;
$headers.='Cc:birthdayarchive@example.com' . “\r\n”;
$headers.='密件抄送:birthdaycheck@example.com' . “\r\n”;
//邮寄
邮件($to、$subject、$message、$headers);

您需要在标题中指定这是一封html电子邮件,以便将其解释为html而不是纯文本

$headers='MIME版本:1.0'。“\r\n”;
$headers.='内容类型:文本/html;字符集=iso-8859-1'。“\r\n”;
$content=“亲爱的$name,

感谢您在name注册。在我们激活您的帐户之前,必须采取最后一步来确认您的电子邮件地址。”; $content.=“

请注意-您必须完成最后一步。您只需访问此URL一次即可确认您的电子邮件地址。

即可完成注册,”; $content.=“请访问此URL:




”; $content.=“如果您在注册时仍有问题,请联系我们的支持人员或联系我们的。

”; $content.=“祝您一切顺利,
姓名
”; 邮件($custary['email'],“请确认您的电子邮件”,$content,$headers);
<代码> > p>您可以考虑使用外部库来处理HTML电子邮件。我过去成功地使用过。

我也尝试过。很抱歉,我的代码中没有包含这个。下面是我放在这里的
$headers=“MIME版本:1.0rn”$标题。=“内容类型:文本/html;字符集=iso-8859-1rn”$标题。=“发件人:名称\r\n”$headers=“MIME版本:1.0rn”$标题。=“内容类型:文本/html;字符集=iso-8859-1rn”$标题。=“发件人:名称\r\n”但没有运气。$headers.=“内容类型:text/html;charset=iso-8859-1rn”;缺少反斜杠\r\n
$headers  = "From: $email\r\n" . "Reply-To: $email\r\n" . "CC: $cc\r\n";

$message  = "$logmsg \r\n\n";
$message .= "Name : $name \r\n\n";
$message .= "Email : $email \r\n\n";
$message .= "Phone No : $phone \r\n\n";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$content="Dear $name, <br /><br />Thank you for registering at NAME. Before we can activate your account one last step must be taken to confirm your email address .";
$content.="<br /><br />Please note - you must complete this last step. You will only need to visit this URL once to confirm your email address.<br /><br />To complete your registration,";
$content.=" please visit this URL:<br /><a href='$link1' target='_blank'> $link1 </a><br /><br /><br />";
$content.="If you are still having problems signing up please contact a member of our support staff at&nbsp;<a href='mailto:email@gmail.com'>email</a> or contact our <a href='$link2'>customer care</a>. <br /><br />";
$content.="All the best,<br />NAME<br />";
mail($custArray['email'],"Please Confirm Your Email",$content, $headers);
$headers  = "From: $email\r\n" . "Reply-To: $email\r\n" . "CC: $cc\r\n";

$message  = "$logmsg \r\n\n";
$message .= "Name : $name \r\n\n";
$message .= "Email : $email \r\n\n";
$message .= "Phone No : $phone \r\n\n";