簡體   English   中英

php郵件中的按鈕鏈接

[英]Button Link inside php mail message

我正在嘗試發送一封自動電子郵件,其中包含一個用於下載報告的按鈕; 我的問題是我似乎無法找到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); 

您需要使用網站上托管的圖片。 只需指向報告的鏈接即可。 由於未定義CSS,因此在電子郵件中無用。

<a href="link _to_report"><img src="link_to_image_source" /></a>

將其放在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的“不要做”的信息

您需要添加其他一些標頭參數:

$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); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM