Back to index
Last updated: 2016/09/17
Initial document.

Introduction

(If you're an advanced user you can skip directly to section three - keeping in mind to backup first and remembering to have Thunderbird closed whilst you edit the 'prefs.js' file); otherwise if you're unsure of where your Thunderbird profile is stored (and therefore where the 'prefs.js' file is) I will try to guide you along the process.

Quite a while back I wrote what would become a document explaining how to change the order of email accounts in Thunderbird. The problem is Thunderbird does not support this option but instead stores the accounts in something of a linked-list which only shrinks when the user deletes a specific account: the first account added is at the top; the second account added is the one just below the first; etc. This was problematic for me because I have so many accounts and some of the later accounts had higher priority for me. Yet Thunderbird does not offer this capability. It is true there might be an add-on but I took it as a challenge to figure it out. What follows explain how to do it the manual way. But first a warning and reminder:

Warning: You do regularly backup don't you? If you don't you really should BUT in either case you absolutely must backup the 'prefs.js' file (see next section) in your Thunderbird directory (even if you do backup regularly you should do this prior to following these steps)! Don't even think about touching the file without taking precautions for even the most experienced can make mistakes (also: if you were to lose power in the middle of editing the file and you don't have a UPS what will the state be of the file?).

Reminder: Do not do this whilst Thunderbird is running! You must decide the order you would like the different accounts in ahead of this for that reason (not strictly true as you see the email accounts in the process but it might be easier for those who are primarily visual?).

The prefs.js file

The file you need to edit is 'prefs.js'. It has much more than just email account, identities and addresses but you needn't concern yourself with anything but those.

So where is the 'prefs.js' file? For the purpose of this document I will have the default directory for the user 'luser':

/home/luser/.thunderbird
But under this directory you'll find another file called
profiles.ini
. The 'profiles.ini' is in the form of the Windows INI file format and what you're looking for is which profile is the default (presuming it is this profile you wish to update). You can cat the 'profiles.ini' file, open it in a text editor or view in whatever way works for you. Each profile has its own section starting with its name between square brackets ('[' and ']'). If you see under it the line:
Default=1
then you have found the correct profile; take note of the path and cd to it.

Filter file 'prefs.js' for email accounts, identities and manager

In order to reorder your email accounts in whatever order you wish you must know about three keys in the 'prefs.js' file. The following command will print those keys out:

$ grep -E 'id[0-9]+\.useremail|account[0-9]+\.identities|accountmanager\.accounts' prefs.js

The format is:

user_pref("key", "value");
But I'm only including the key and value themselves. The following is a fictional account (or actually they are fictional accounts) but should serve to demonstrate.
"mail.account.account1.identities" = "id3"
"mail.account.account3.identities" = "id7"
"mail.accountmanager.accounts" = "account1,account3"
"mail.identity.id3.useremail" = "lusers@example.net"
"mail.identity.id7.useremail" = "users@example.org"

Understanding the keys you must edit

From the output you have three types of keys:

  1. mail.account.account[0-9]+.identities
  2. mail.accountmanager.accounts
  3. mail.identity.id[0-9]+.useremail
The value of the first key type allows you to determine which mail identity is is which email account. For example here it states account1 has the ID 3 and that ID is 'lusers@example.net'; meanwhile account3 has the ID 7 and ID 7 is 'users@example.org'. Then you simply change the order of the value of:
mail.accountmanager.accounts
to the order you desire. Once you launch Thunderbird again if you didn't make an error it should have updated the order. That's all there is to it.