我正在尝试发送一封带有下载报告按钮的自动电子邮件;我遇到的问题是,我似乎找不到php链接显示为按钮甚至链接,它只是打印出代码。
我的代码如下;任何建议都将不胜感激。感谢
$to = "$email";
$subject = "Alert Report";
$message = "
<a href='"http://www.mywebsite.com/test.php?id={$id}'" class='button'>Download Report</a>
";
$from = "My Website";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
您需要添加一些其他头参数:
$to = "$email";
$subject = "Alert Report";
$message = "
<a href='"http://www.mywebsite.com/test.php?id={$id}'" class='button'>Download Report</a>
";
$headers = "From: $from'r'n";
$headers .= 'MIME-Version: 1.0' . "'r'n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "'r'n";
mail($to,$subject,$message,$headers);
将其放入html
标签中
//begin of HTML message
$message = "
<html>
<body >
<input type='"button'" value='"Download Report'" onclick='"location.href='your site with param';'">
</body>
</html>
";
$headers = "From: $from'r'n";
$headers .= "Content-type: text/html'r'n";
正如Fred在评论中指出的那样,避免使用外部css。请改用内联。有一些可用的博客,您可以了解电子邮件css 的Do’s Don’t
您需要使用网站上托管的图像。只需指向报告的链接。CSS在电子邮件中是无用的,因为它没有定义。
即
<a href="link _to_report"><img src="link_to_image_source" /></a>