I am combining several HTML tables to a $message and I will pass it to the mail body as below.
// Send the mail
if(smtp_mail($To,$cc, $Subject, $message, $headers))
{
echo "Mail Sent";
}
else
{
echo "Some error occured";
}
I have printed $message variable by using print($message) and below is the output.
Please find below..<h2>Japan </h2><table border="1"><tr><th>Quality Metric</th><th>2023-02-10</th><th>2023-02-11</th><th>2023-02-12</th><th>2023-02-13</th></tr><tr><td>AC</td><td style="background-color: lightcoral;">40.54 62.97</td><td style="background-color: lightcoral;">36.28 57.75</td><td style="background-color: lightcoral;">40.09 60.06</td><td style="background-color: lightcoral;">39.71 52.93</td></tr><tr><td>DC</td><td style="background-color: lightgreen;">24.84 22.82</td><td style="background-color: lightgreen;">22.92 20.31</td><td style="background-color: lightgreen;">20.89 21.37</td><td style="background-color: lightcoral;">17.62 23.29</td></tr></table>
when I check that using https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_html I can see the table as I want.
but when I receive the mail the table has messed up and some colors cannot see.
can some one comment on my issue?
>Solution :
Email is finicky when it comes to rendering HTML, let alone knowing all the ‘named’ colours.
The safest thing to do with colours is always to use the 6 number codes – i.e. the HEX codes.
For example, instead of:
<td style="background-color: lightcoral;">
use something like this:
<td style="background-color: #445566;">
or whatever the HEX for lightcoral is 😉