Control Thunderbird In The Enterprise

January 25, 2008

Back when I was actively coding FirefoxADM, one question I would get quite often was:  “when are we going to see ThunderbirdADM?”.

My answer was that I really wanted to do this, to allow users to be able to control both Firefox and Enterprise as either their main or alternative browser and email clients.  Unfortunately, I didn’t really get round to it due to the unwieldy way I built FirefoxADM.

So let’s look at it now…

Controlling Thunderbird actually works in exactly the same way as the way that was the basis for FirefoxADM.  The big problem is, because things have been moved around, some functionality changed, it wasn’t always obvious how this was done.  Now, from this point, I am going to talk in a Windows context.  However, as far as I can tell, this should work on all platforms.

First things first:  install Thunderbird and run it for the first time.  To follow some of the prefs, it is better if you use a cleanly built machine, but if you are doing this on your machine, with your own settings in play, be careful!  If you are using it for the first time, set it up as you would want to see it in your enterprise environment if Thunderbird was freshly installed.  The overall aim of this exercise is to take a large number of these preferences you just set up and apply them to users.  You want some to be locked, some to be default and you want them in there automagically when the user first uses Thunderbird.

Navigate to where Thunderbird is installed.  This will usually be C:\Program Files\Mozilla Thunderbird.  The way the enterprise management works in Thunderbird goes all the way back to Netscape.  There was a hidden preference in Netscape called “general.config.filename”.  This preference set the location of a central configuration file.  By default, this file was a ROT 13 file.  ROT is a very simplistic byte shifting encryption.  For example, the word “MARK” would be “NBSL” at ROT 1, “OCTM” at ROT 2 and therefore “ZNEX” at ROT 13.  Fortunately, there is another setting, “general.config.obscure_value” which allows you to set the ROT value.  I prefer ROT 0!  Where do we put this?  Inside the greprefs directory in Mozilla Thunderbird’s installation directory, create a file.  Call it “adm.js“.  Now, let’s put these two settings in there, and call the configuration file tbirdadm.cfg (from the filename, you can see where I’m going with this!):

pref(“general.config.obscure_value”, 0);
pref(“general.config.filename”, “tbirdadm.cfg”);


We now want to get all those settings you made.  Go to your Application Data directory (for Vista users, that’s in C:\Users\<username>\AppData\Roaming, XP/2000 is in C:\Documents and Settings\<username>\Application Data).  There should be a folder there called Thunderbird.  Go in there, into the Profiles directory that is below that and you should see a directory called, well, something.  Its a random name.  Inside that folder you see your profile.  The file we are interested in is prefs.js.  Open it and you will see it looks something like this:


And here you have the settings you really want to push out to your users.  You now have to choose which settings to use.  This is the really tricky part.  There will be a LOT of trial and error at this stage – finding all the right settings can be a pain.  One gotcha with the prefs.js file is it only includes preferences where the user has preference values that are different to those Thunderbird has as default.  If you have a fresh profile as I said earlier, I suggest copy from this file all the preferences that start “user_pref(“mail…”.  Now, in the C:\Program Files\Mozilla Thunderbird directory, create a file called “tbirdadm.cfg”.  Paste all the settings you had in there.  Now, replace all the “user_pref” in that file with “lockPref” (ie.  Edit, Replace) and close the file.

Time to test!  Rename the entire Thunderbird directory from the Application Data directory to Thunderbird.bak.  Fire up Thunderbird.  You are now a first time user using Thunderbird.  Hopefully, Thunderbird will now be using your managed preferences and will automatically have configured Thunderbird to act as you want it to for a first time user.  What’s more, all the settings will be locked from being changed:


Do not be despondent if, when you loaded Thunderbird up, you got an error, or no accounts were set up.  Close Thunderbird, delete the Thunderbird directory, go into the Thunderbird.bak directory and have another look at that prefs.js file.  You might also find that some values seem not locked.  Thunderbird is a tricksy application in that way.  Sometimes, settings aren’t locked or you find there are workarounds.  For example, in that screenshot above, if someone ticks and unticks that Attach this signature box, it unlocks the box.  The problem is, that tick box is not locked, because it never appeared in the prefs.js as unticked is default.  So, you tick the box, close Thunderbird, go to the prefs.js file and find this value:  user_pref(“mail.identity.id1.attach_signature”, true);.  Therefore, you just add:  lockPref(“mail.identity.id1.attach_signature”, false);  to the tbirdadm.cfg file file.  There are plenty more of these to find!

Once you have all that working, you have one last major problem which is, some of the settings are configured to you.  For example, in mine, many of them use my username.  You now have to genericise the settings.  Fortunately, you can use getenv to get Environment Variables.  This is useful because you can change a line like:

lockPref(“mail.identity.id1.draft_folder”, “imap://”);


lockPref(“mail.identity.id1.draft_folder”, “imap://” + getenv(“username”) + “”);

Not all settings are going to be as easy as that to make generic.  Some may even require some user interaction.  Some may require some more programming in the tbirdadm.js file (remember, this is effectively inside Thunderbird, so any javascript code you put in there, Thunderbird will try to execute…).  For instance, their email address and full name may not be things you can set generically and will have to teach users to set themselves (although I think it is the case that in those two examples Thunderbird will demand these are set when you first try to send an email).

I said earlier that you might want to set default settings as opposed to locked ones.  Simple:  find the setting in tbirdadm.cfg and change lockPref to defaultPref.

This is a bit of a wordy skip through the process but its really quite a simple process really.


4 Responses to “Control Thunderbird In The Enterprise”

  1. wolvverine Says:

    Do can thunderbird read this file from network path ???

    pref(”general.config.filename”, “\\server\share\tbirdadm.cfg”);

  2. Mark Sammons Says:

    Everything I have read suggest you need to have the file in that %PROGRAMFILES\Mozilla Thunderbird directory.

    If you are going to try this, use double back slashes for directory locations (eg \\\\server\\share)

  3. Michel Says:


    Do you have an idea why my prefs cannot be changed on a MAC via the interface given?
    If I change any existing mail account, it pops an alert about me having changed something and that I probably want to change something else.
    I can then only cancel the complete dialog and my only recourse is to manually edit prefs.js each time
    it is like prefs.js suddenly becomes readonly…
    I have not been able to find anything on the web including bugzilla

  4. I’m writing a series of articles on mission control desktop – autoconfig. Check here:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: