Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.3: Use a local stylesheet to control Mail.app HTML Apps
We recently switch to using an Exchange server here at work. I'm accessing the server via IMAP, as I used to access our old server via IMAP too, and I've noticed that all of my incoming plain-text email has now become unreadable. It became unreadable because the Exchange server is changing all incoming text/plain email to multi-part with a text/plain part and a text/html part, and Mail is showing me the text/html part. And Exchange, in its infinite wisdom, is putting tags with SIZE=2 attributes on every line. For my monitor, size 2 is too small to read easily.

Setting the default font for messages doesn't seem to have any effect; while it may set the font for text outside of a tag, it doesn't do the trick for these tags that Exchange is putting in. I've fixed this by applying a local style sheet to the HTML rendering engine, and getting it to work in Mail.app as well as in Safari.

As you may know, you can apply a local style sheet, after the default style sheet but before the Web page's style sheet, to the Safari HTML rendering engine, in the Advanced pane of Safari preferences. Unfortunately, you can't do this in Mail -- but the engine allows it, if you can manage to tell it to.

To do this, first create a local style sheet. In my case, I named this ~/benlocal.css, but it can really be anything you want. In the style sheet, put something like the following:

font[size="1"] {
    font-size: 10pt;
}
font[size="2"] {
    font-size: 11pt;
}
font[size="3"] {
    font-size: 12pt;
}
You can define sizes for all seven HTML font sizes if you want; in my case I mainly wanted size 2 to be readable, so this was sufficient. Next, make sure that Mail.app is not running; quit it if it is, since we're about to manually edit its prefs file. Open ~/Library -> Preferences -> com.apple.mail.plist, after making a backup copy of it, in a text editor. Near the bottom of the file, find the WebKit attributes, which look something like this:
<key>WebKitMinimumFontSize</key>
  <integer>9</integer>
  <key>WebKitStandardFont</key>
  <string>Helvetica</string>
  <key>dv  com.apple.soundmgr._DV Sound Output Settings</key>
  <data>
  fQAAAA==
  </data>
Now insert the following text before the "DV Sound Output Settings" line:
<key>WebKitUserStyleSheetEnabledPreferenceKey</key>
  <true/>
  <key>WebKitUserStyleSheetLocationPreferenceKey</key>
  <string>~/benlocal.css</string>
Replace the ~benlocal.css with the path to your style sheet you created above. If you've put this stuff in the right place, it should look like this:
<key>WebKitMinimumFontSize</key>
  <integer>9</integer>
  <key>WebKitStandardFont</key>
  <string>Helvetica</string>
  <key>WebKitUserStyleSheetEnabledPreferenceKey</key>
  <true/>
  <key>WebKitUserStyleSheetLocationPreferenceKey</key>
  <string>~/benlocal.css</string>
  <key>dv  com.apple.soundmgr._DV Sound Output Settings</key>
  <data>
  fQAAAA==
  </data>
Save and close, and launch Mail, and you're done!

Note that I believe you could also achieve a similar goal by changing the WebKitMinimumFontSize here, from 9 to something larger, but I think doing it this way is a little more elegant, because it lets you explicitly set the actual size for each of the seven possible values (and because if you set the minimum size to something like 12, the bottom three sizes will all be the same size on the screen).

Also note that you can do the exact same thing with Safari, except that Safari's preferences window allows you to set the minimum size and apply a local style sheet without manually hacking the prefs plist file. I figured out how to do this to Mail by observing what those GUI settings did to Safari's prefs file, and by knowing that Mail uses the same rendering engine internally, and noticing that its prefs file had the same set of keys.

    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[24,448 views]  

10.3: Use a local stylesheet to control Mail.app HTML | 17 comments | Create New Account
Click here to return to the '10.3: Use a local stylesheet to control Mail.app HTML' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.3: Use a local stylesheet to control Mail.app HTML
Authored by: landers on Feb 27, '04 12:01:20PM

Fantastic, thanks.

BTW I tried changing the WebKitMinimumFontSize but it changes back to 9 when I restarted Mail.



[ Reply to This | # ]
10.3: Use a local stylesheet to control Mail.app HTML
Authored by: brettmjohnson on Feb 27, '04 01:42:52PM

Excellent. The real question, of course, is why Exchange converts plain text mail to HTML mail in the first place. I send plain text messages for very good reasons. But it not unusual for Microsoft products to subvert the very best intentions of its users.



[ Reply to This | # ]
10.3: Use a local stylesheet to control Mail.app HTML
Authored by: Djehuti on Feb 27, '04 02:16:16PM

Indeed. And that is a question I have asked, but I do not expect to get a satisfactory answer. ;)



[ Reply to This | # ]
10.3: Use a local stylesheet to control Mail.app HTML
Authored by: kclemson on Feb 27, '04 11:46:11PM

This is configurable in Exchange, it's unfortunate that it's the default. On the properties of the IMAP virtual server you can specify what format the messages should be available in. Just uncheck HTML.



[ Reply to This | # ]
10.3: Use a local stylesheet to control Mail.app HTML
Authored by: aranor on Feb 27, '04 02:30:04PM
BTW, you can use the defaults command to achieve this same effect.
defaults write com.apple.Mail WebKitUserStyleSheetEnabledPreferenceKey -bool True
defaults write com.apple.Mail WebKitUserStyleSheetLocationPreferenceKey '~/benlocal.css'


[ Reply to This | # ]
10.3: Use a local stylesheet to control Mail.app HTML
Authored by: Djehuti on Feb 27, '04 03:28:12PM

Brilliant! This hint could have been much shorter if I had realized that. Thanks!



[ Reply to This | # ]
10.3: Use a local stylesheet to control Mail.app HTML
Authored by: brettdog on Feb 27, '04 05:03:37PM

I would like to change the color also to identify when and how often this happens. I suppose I could add the line

color: green;

under each font-size line to show this in green.

---
brettdog



[ Reply to This | # ]
10.3: Use a local stylesheet to control Mail.app HTML
Authored by: Anonymous on Oct 12, '04 03:20:49PM

Thank you!! I felt like I was going blind with all of those Outlook-originated emails. (Strangely, they look ok in Safari; the default Mail style sheet must not be that great.) Finally I have some control over the situation again.



[ Reply to This | # ]
10.3: Use a local stylesheet to control Mail.app HTML
Authored by: prk on Feb 05, '05 04:06:11PM

Well, I was told to backup my preferences file, but I didn't. What a dumb ass. I lost all my settings because I didn't do a simple copy. So I ran over to my CD backups and found out that I didn't have a backup of my preferences directory. Uhg.

Be sure to back things up before you mess with them. Now I'm off to redo all my settings and all my rules. Arg.



[ Reply to This | # ]
10.3: Use a local stylesheet to control Mail.app HTML
Authored by: prk on Apr 24, '05 12:39:11AM

The latest Mac OS X update has broken this. Is there something different to do now?



[ Reply to This | # ]
10.3: Use a local stylesheet to control Mail.app HTML
Authored by: prk on May 17, '05 11:48:27AM

This fix does not work in Tiger also. Please, someone, anyone, is there a fix for this? The tiny fonts are very annoying.



[ Reply to This | # ]
Exhange Mail in Tiger
Authored by: Deut3221 on Jun 09, '05 09:48:53PM

For some reason, in Tiger 10.4.1 I am getting PC mail sent through an Exchange Server that is GIANT size font. Anyone else experiencing this? (I know; the exact opposite that we used to get -- microscopic size font from Outlook Express. Weird.)



[ Reply to This | # ]
Solution for small fonts in Tiger Mail, finally!
Authored by: sjoerd on Aug 29, '05 04:51:31PM

Having been annoyed with this old problem coming back since upgrading to Tiger (10.4.2), I finally got so annoyed that I spent some time finding a solution - with success!

It appears that Mail 2.0 (up to 2.0.2 at least) ignores the user style sheet which solved the problem in earlier versions. What is worse, it overrides the Webkit size defaults! I tried putting the contents of the local stylesheet into the global Webkit stylesheet, but this did not help. Btw, this file is at:

/System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Resources/html4.css

The funny thing is that adding to this file for example:

font[size="2"] {
  color: green;
}

DOES affect the font displayed in Mail. Yet a font-size propery is ignored!

The final solution is to edit com.apple.mail.plist and add a key MinimumHTMLFontSize. I set the (numerical) value of this key to 12. Remember to close Mail.app before editing the preference file (use plist editor, or a defaults command from the terminal).

[ Reply to This | # ]

Solution for small fonts in Tiger Mail, finally!
Authored by: andrei on Sep 26, '05 08:02:30PM

Hello sjoerd,

Thank you very much for your post about this issue. I know quite a bit of time has passed, so I hope you may see my question.

I followed your instructions about editing the com.apple.mail.plist with the plist editor that came with the developer tools. The path to the file I am editing is:

/System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/English.lproj/ExceptionsDatabases/com.apple.mail.plist

I do not see any changes after altering and saving the p-list file. (I had to modify its permissions so that I could edit it. This shouldnt effect anything however, right?) I did successfully change the font color with the css file as you pointed out.

I entered the MinimumHTMLFontSize entry at the top level under "root" in the plist. Nothing happened. I tried it as well under UIElement and AXStaticText and AXTextField subheadings. Still nothing. The class column for my entry is listed as "number" and i have "12" in the value.

I'm sure I am doing something wrong. Please, help me!!!!!!

Thanks a million!

Andrei



[ Reply to This | # ]
Solved!!!!!!
Authored by: andrei on Sep 26, '05 09:05:35PM

Ok, I am a moron. My unix mindset told me to do a "locate" command in the terminal for that file, which brought up that really strange path for the file.

Simply doing a spotlight search, like a good os x user should do, brought me to another plist file with path /Users/andrei/Library/Preferences/com.apple.mail.plist

Thats what you need to use guys. Works perfectly. Sorry for cluttering up space on the boards for my stupidity!

Take care,

Andrei



[ Reply to This | # ]
Solution for small fonts in Tiger Mail, finally!
Authored by: FlaSheridn on Apr 20, '06 09:57:25AM

> or a defaults command from the terminal

To be precise, the following worked for me:

defaults write com.apple.mail MinimumHTMLFontSize 14

Thanks very much for the tip; I'd had to use a Keyboard Maestro macro to make a lot of our corporate email readable.



[ Reply to This | # ]
10.3: Use a local stylesheet to control Mail.app HTML
Authored by: bkemper on Jul 05, '08 09:53:45AM

OK, so now how do you do this in 10.5 (Leopard)?



[ Reply to This | # ]