从 php 邮件程序打印电子邮件时,gmail 不会应用 css

gmail wont apply css when printing email from php mailer

我正在尝试制作一个 phpmailer 在打印时应用一种样式(主要是字体大小)以使其全部适合标准打印纸。但是当在 gmail 中并选择打印时,我无法应用样式。

 $mail->Body="
 <?php
 <!DOCTYPE html>
 <html>
 <head>
<title>test email</title>
<style>
h1 {
color: maroon;
font-size: 10px;
}
@media print { 
h1 {
color: maroon;
font-size: 10px;
}
}
</style>
</head>
<body>
<h1>html EMAIL IS COMING SARA</h1>
</body>
</html> 
";

我已经试过了,但是邮件根本发不出去。我收到以下信息:

PHP Parse error: syntax error, unexpected 'color' (T_STRING)

$mail->Body="
<?php
 <!DOCTYPE html>
<html>
<head>
<title>test email</title>
</head>
<body>
<h1 style="color:blue;">html EMAIL IS COMING SARA</h1> 
</body>
</html> 
 ";

这是因为 php 字符串引号 "

使用以下代码:

$mail->Body="

 <!DOCTYPE html>
<html>
<head>
<title>test email</title>
</head>
<body>
<h1 style='color:blue;'>html EMAIL IS COMING SARA</h1> 
</body>
</html> 
 ";