?
Solved

Programatically create a account in Mozilla ThunderBird

Posted on 2009-04-16
4
Medium Priority
?
1,972 Views
Last Modified: 2012-05-06
Hi,

   I have to create a tool that will take the gmail address and configure the account in Thunderbird . Is it possible to do that using some scripts or VB program. I have got a similar script that configures the account in outlook by entering the details in registry. Can it be done in the similar way. If  so please help me.

Thanks in advance.

Priya
0
Comment
Question by:Priyadarshni
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:sda100
ID: 24155689
http://ick2.wordpress.com/2008/01/25/control-thunderbird-in-the-enterprise/

And the text (in case the link dies)...


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 wasnt 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 Thunderbirds installation directory, create a file.  Call it adm.js.  Now, lets put these two settings in there, and call the configuration file tbirdadm.cfg (from the filename, you can see where Im 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, thats 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.  Whats 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 arent 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://msammons@mailserver.com/Drafts);
to
lockPref(mail.identity.id1.draft_folder, imap:// + getenv(username) + @mailserver.com/Drafts);
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.
0
 

Author Comment

by:Priyadarshni
ID: 24182702
Thank you for replying..
I went through the link, But how do i use that to create account programatically? Do i have to write into prefs.js file??

0
 
LVL 9

Accepted Solution

by:
sda100 earned 2000 total points
ID: 24188925
Yes! - If you can edit the prefs.js file (while Thunderbird is closed, because it only updates prefs.js on shutdown) then you'll be able to configure it to your heart's content.  There are lots of ways to programatically change the text in prefs.js (ie. a simple batch script) because it doesn't have to be in any order.  However, you may want to try SED for windows to help?

http://gnuwin32.sourceforge.net/packages/sed.htm

Steve
0
 

Author Closing Comment

by:Priyadarshni
ID: 31570862
Thank you
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month17 days, 3 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question