2

I'm trying to make a phpmailer that when printed applies a style, mostly font size, to get all of it to fit on a standard piece of printer paper. But when in gmail and selecting print I can't get the style to be applied.

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

I have tried it this way but the email wont send at all. I recieve the following:

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> 
 ";
David Harris
  • 2,332
  • 1
  • 13
  • 25
jlitt1
  • 227
  • 1
  • 3
  • 11

1 Answers1

1

This is because of php string quotes "

Use the following code:

$mail->Body="

 <!DOCTYPE html>
<html>
<head>
<title>test email</title>
</head>
<body>
<h1 style='color:blue;'>html EMAIL IS COMING SARA</h1> 
</body>
</html> 
 ";
saurabh kamble
  • 1,510
  • 2
  • 25
  • 42