2

I have a test program that logs the users answers and grade to a log file. I also have it email off this in a nicely formatted html email to the administrator of the tests.

For the most part, this system works. But strangley I've noticed that different email clients are removing portions of the code. It's a table, so a lot of the code is very repetitive, and the sections that get removed are the same every time for each email client (outlook and gmail are the ones I've tested). So for example, if I have a section of the table:

<tr><td style="background:#a66;text-align:center">This is the answer</td></tr>

Then it may come out as:

<tr><td style="backgrouter">This is the answer</td></tr>

And I can't find any correlation between where it does this in each file. Sometimes its near the end, sometimes near the beginning. In some cases, if the test was particularly long, it won't even finish the email.

I have my php outputting the same exact html to a log file on the server, and that always comes out perfect.

What's going on? How do I fix it?

1
  • d:#a66;text-align:cen Weird thing to have stripped out. Thought I'd clearly show that. Almost like it got spell checked :) Gmail stripping styles I can understand, Outlook less so.
    – ficuscr
    Oct 22, 2012 at 22:38

4 Answers 4

1

I think this is because of the 998 characters per line limitation on MIME Email.

For more details, you can see below posts:

Reasoning behing 76 being the line length limit for MIME sections, as defined by RFC 2045? (See answer by appleleaf)

HTML safe wrapping of long lines

My solution is to add "\r\n" between HTML tags so it won't exceed 998 characters per line. This works for me.

0

The one thing I can think to try is to append an !important to the each CSS statement.

<td style="background:#a66 !important;text-align:center !important">

Oh, and just noticed you are missing a closing ;.

2
  • c.c The OP is not missing a closing ;.
    – Daedalus
    Oct 22, 2012 at 22:45
  • Agreed. Does make you wonder though if any parsing done by Google might be impacted. I really find it strange though that both Google and Outlook have the exact same symptom. Makes me skeptical that issue is not local.
    – ficuscr
    Oct 22, 2012 at 22:51
0

That is weird!

Ok, firstly, have you tried spacing and terminating all the styles? eg:

<tr><td style="background-color: #aa6666; text-align: center;">

Secondly, it may be some strange HTML interpretation that Gmail is picking up on although I can't think of a reason for this to happen (eg. style names or reserved function names etc).

Otherwise, I'm stumped. I've only ever seen this happen with yahoo mail, where the HTML in an email broke the yahoo mail layout...

I'd be tempted to use css classes and style them inside a style tag. I've never seen them break.

0

I am afraid your problem has a deeper problem.

Those clients have some obscure way of processing data, and end up repeatably sent mails from same email dress to render it as it was a quote from some other mail.

I would advise you to check the html consistency of the mails, and to read up suported html for emails.

Also make sure that your email header is saying it is a html formatted email and not plain text. Formatting in the header is also important i would command utf8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.