爲什麼不使用mail()php將郵件發送到Gmail時在電子郵件中顯示類css?爲什麼在使用mail()php將郵件發送到Gmail時不能在電子郵件中顯示類css?
我測試這個代碼發送電子郵件到Hotmail它顯示像這樣的電子郵件
但是當我測試這個代碼發送電子郵件到Gmail中它的表現是這樣的。
它沒有表現出類=「按鈕」相同,如Hotmail我該怎麼辦呢?
<?PHP
include("connect.php");
$to = "[email protected]";
$subject = "test email";
$message = "
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<style type='text/css'>
.button{
color: #a7a7a2;
background: green;
padding: 2px 14px;
border-radius: 10px;
}
</style>
</head>
<body style='margin: 0; padding: 0;font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;'>
<table align='center' style='margin:auto;'>
<tbody>
<tr>
<td class='button'>
<a href='test.php' target='_blank' style='padding: 11px 0px; display:block; text-decoration:none; color:#000; font-size:16px; text-align:center; font-family:arial; font-weight:bold'>TEST BUTTON</a>
</td>
</tr>
</tbody>
</table>
</body>
</html>
";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: EXAMPLE <[email protected]>' . "\r\n";
$headers .= 'Return-Path: [email protected]' . "\r\n";
mail($to, $subject, $message, $headers, '[email protected]');
?>
在你的CSS而不是'背景'嘗試'bgcolor'或'background-color' – Chris
@Chris - 我測試過但不能工作,謝謝^^可能是gmail不生成類似hotmail和yahoo的類? –
也許最好直接設計'a'而不是'td'? – Chris