我正在尝试发送一封自动发送的电子邮件,其中包含一个下载报告的按钮;我的问题是,我似乎无法找到显示为按钮甚至链接的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);
答案 0 :(得分:0)
您需要使用您网站上托管的图片。只需指向报告的链接即可。 CSS在电子邮件中没用,因为它没有定义。
即
<a href="link _to_report"><img src="link_to_image_source" /></a>
答案 1 :(得分:0)
将其放在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";
正如评论中所指出的那样,请避免使用外部CSS。请使用内联。有很少的bolgs可供您了解Do's Do not for email css
答案 2 :(得分:0)
您需要添加一些其他标头参数:
$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);