1

在这里我在发送邮件时遇到问题。它正在正确地去杠杆,但是当我尝试使用 HTML 标签设计邮件正文时,它会将相同的 html 标签发送到我的电子邮件收件箱。我该如何克服这个问题,请告诉我。

这里的PHP代码:

$to = "$email";
$subject = "Test mail";
$message = '<!Doctype html><html><head><title>Confirm Link</title></head><body><div style="color:blue">Thank u for registering with us </div>
<div> Hi'.$name.' Please click the below link to activate your accont</div><div><a href="http://www.websitename.com/test2/activation.php?id='.$uid.'&name='.$name.'&mail='.$email.'">Active your account now</a></div> </body></html>';

$from = "abc@gmail.com";
$headers = "From:" . $from;

这里我发送的电子邮件收件箱消息:这里设计不工作它显示与我的程序代码相同。请帮助我。

确认链接感谢您向我们注册 HiSrinivas 请点击以下链接激活您的帐户 立即激活您的帐户

4

3 回答 3

4
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

笔记:

如果打算发送 HTML 或其他复杂邮件,建议使用 PEAR 包 » PEAR::Mail_Mime。

参考

于 2013-10-09T06:37:37.370 回答
0

发送 HTML 电子邮件:

<?php
$to = "somebody@example.com, somebodyelse@example.com";
$subject = "HTML email";

$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
$headers .= 'From: <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";

mail($to,$subject,$message,$headers);
?>
于 2013-10-09T06:37:55.823 回答
0

问题可能是您没有设置邮件标头。尝试这个:

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail($to, $subject, $message, $headers);
于 2013-10-09T06:38:42.283 回答