Is there any automation for bulk adding eMail accounts?

User Help for Mozilla Thunderbird
undefined334
New Member
Posts: 1
Joined: January 1st, 2017, 6:05 pm

Is there any automation for bulk adding eMail accounts?

Post by undefined334 »

Hey there,

I have to add around 120 IMAP accounts to thunderbird.
Is there a way to edit a file or to get them pulled from excell oder a CSV or am I doomed to do one by one?

Looks like this:
support@webproject001.com-Password
support@webproject002.com-Password
support@webproject003.com-Password
support@webproject004.com-Password
support@webproject005.com-Password
support@webproject006.com-Password
support@webproject007.com-Password
support@webproject008.com-Password
support@webproject009.com-Password


Thanks
User avatar
tanstaafl
Moderator
Posts: 49647
Joined: July 30th, 2003, 5:06 pm

Re: Is there any automation for bulk adding eMail accounts?

Post by tanstaafl »

Not that I'm aware of. The utilities mentioned in http://kb.mozillazine.org/Configuration ... nistrators are mainly for remote deployment. You could manually edit prefs.js after adding one account normally (so that you have something to copy & paste, and then edit) if you understand its syntax, but I wouldn't recommend it. Using the Add Mail Account Manually add-on might be quickest as it will eliminate testing that the username/password can be used to login and the delay while it searches for configuration data in the Mozilla ISP database.

If you own your own domain I suggest you investigate whether you can configure the mail server to store all mail sent to any address in that domain in one mailbox. That would let you add a single account in Thunderbird. You could add a multiple identity for each address to the account so that you could send using any of the 120 addresses as the From: address.
xdelicacyx
Posts: 111
Joined: April 16th, 2015, 3:15 am

Re: Is there any automation for bulk adding eMail accounts?

Post by xdelicacyx »

Hi tanstaafl, does any of the tools you listed allow providing numerous accounts from a text file as undefined showed ?
ideally, it would be great if any email client could import csv email accounts (not contacts).

I saw two of them to add only one account at a time..

My wish >

ex:
name, email name, pop server, port, smtp server, port, ssl yes/no, 1min (checking time)

what would be the best way to accomplish that ?
User avatar
tanstaafl
Moderator
Posts: 49647
Joined: July 30th, 2003, 5:06 pm

Re: Is there any automation for bulk adding eMail accounts?

Post by tanstaafl »

There are numerous configuration tools to automate adding accounts but I don't know if any of them support .csv files, and most of them are targeting an enterprise where an admin wants to remotely deploy a few accounts per PC (not add 120 accounts to a single PC).
User avatar
tanstaafl
Moderator
Posts: 49647
Joined: July 30th, 2003, 5:06 pm

Re: Is there any automation for bulk adding eMail accounts?

Post by tanstaafl »

In the future please create a new thread if the old thread is over a year old.
xdelicacyx
Posts: 111
Joined: April 16th, 2015, 3:15 am

Re: Is there any automation for bulk adding eMail accounts?

Post by xdelicacyx »

i see, if you have a reference or two excluding the enterprise (local) ex, that would kind to share
User avatar
tanstaafl
Moderator
Posts: 49647
Joined: July 30th, 2003, 5:06 pm

Re: Is there any automation for bulk adding eMail accounts?

Post by tanstaafl »

If I knew of any, I would have already mentioned them. Unfortunately what you want to do is not a typical use case. The only other alternative I can think of is to manually add one set of the account settings to prefs.js using a text editor, copy and paste it 119 times, and then edit each preference as needed. However, that is error prone, hard to debug if you are not familiar with how Thunderbird uses/assigns ids and probably take a lot longer than using the new account wizard.

See the storage section of https://developer.mozilla.org/en-US/doc ... counts_API
xdelicacyx
Posts: 111
Joined: April 16th, 2015, 3:15 am

Re: Is there any automation for bulk adding eMail accounts?

Post by xdelicacyx »

nice, but i'm not a coder.. & i was looking for a stupid exe.. still havent finished searching, the complexity of tb's prefs arent worth trying to play with it, it'll cost me as much time as adding them through tb's interface.
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: Is there any automation for bulk adding eMail accounts?

Post by morat »

The following extension is really simple. The create account code is in the am.js file in the .xpi archive.

Add Mail Account Manually
http://freeshell.de/~kaosmos/index-en.html#addmanual

If the extension still works with the release build, then you could hire a developer to code a script to run in the error console.
User avatar
tanstaafl
Moderator
Posts: 49647
Joined: July 30th, 2003, 5:06 pm

Re: Is there any automation for bulk adding eMail accounts?

Post by tanstaafl »

I'd looked at that add-on but ignored it since the author didn't list it in

"The extensions compatible with Thunderbird 60 are ATTACH EXTRA TOOLS, HEADER TOOLS LITE, IMPORT EXPORT TOOLS, PRINTINGTOOLS, PROFILESWITCHER, SEND AND FILE (in progress), THUNDERBIRD-DONTRESTORE TABS (you can find all of them at https://addons.thunderbird.net) and MOREFUNCTIONSFORADDRESSBOOK (available on this site)."

However, if you set extensions.strictCompatibility false using the config editor it will install and it works. The add-on doesn't save the username/password for you or add a smtp server (it defaults to using the default SMTP server). It also doesn't know about OAuth2 authentication which could be problem for yahoo and gmail accounts.

The current version of the new account wizard is pretty quick. If you press "manual config" in it that adds the account as is (without checking the login works), and creates a corresponding smtp server. It lies about saving the username/password for the password wizard though (if you kept the checkbox checked to save the password) if you do that.
xdelicacyx
Posts: 111
Joined: April 16th, 2015, 3:15 am

Re: Is there any automation for bulk adding eMail accounts?

Post by xdelicacyx »

What morat proposes has no automation, i have to fill in quite everything. that's a totally indirect proposal when my aims to add numerous email accounts created line by line.
if anyone's interested, either tanstaafl or morat or someone else in creating a csv2tbemailaccount xpi or exe at a correct price knowing i'm on gov's help, maybe i could do it.
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: Is there any automation for bulk adding eMail accounts?

Post by morat »

tanstaafl wrote:It also doesn't know about OAuth2 authentication which could be problem for yahoo and gmail accounts.
I can add mail accounts manually with OAuth2 authentication using the error console.

Code: Select all

// add mail accounts manually

(function () {

  var arr = [
    ["abracadabra@gmail.com", "Harry Potter"], // google imap account 1
    ["hocuspocus@gmail.com", "Ron Weasley"],   // google imap account 2
  ];
  var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].
    getService(Components.interfaces.nsIMsgAccountManager);
  for (var i = 0; i < arr.length; i++) {
    var username = arr[i][0];
    var hostname = "imap.googlemail.com"; // imap.googlemail.com or pop.googlemail.com
    var type = "imap"; // imap or pop3
    var server = accountManager.createIncomingServer(username, hostname, type);
    server.port = 993; // 993 or 995
    server.socketType = 3; // Components.interfaces.nsMsgSocketType.SSL;
    server.authMethod = 10; // Components.interfaces.nsMsgAuthMethod.OAuth2;
    if (server.authMethod == Components.interfaces.nsMsgAuthMethod.OAuth2) {
      server.setCharValue("oauth2.scope", "https://mail.google.com/");
      server.setCharValue("oauth2.issuer", "accounts.google.com");
    }
    server.loginAtStartUp = true; // [check] Check for new messages at startup
    server.doBiff = true;         // [check] Check for new messages every    minutes
    server.biffMinutes = 15;      //         Check for new messages every 15 minutes
    server.prettyName = username;
    server.valid = true;
    var identity = accountManager.createIdentity();
    identity.fullName = arr[i][1];
    identity.email = username;
    identity.valid = true;
    var account = accountManager.createAccount();
    account.addIdentity(identity);
    account.incomingServer = server;
    if (!accountManager.defaultAccount) {
      accountManager.defaultAccount = account;
    }
  }

})();

Code: Select all

// inspect server and identity properties

(function () {

  var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].
    getService(Components.interfaces.nsIMsgAccountManager);
  var allServers = accountManager.allServers;
  var allIdentities = accountManager.allIdentities;
  console.log("server properties");
  for (var i = 0; i < allServers.length; i++) {
    var currentServer = allServers.queryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
    console.log(currentServer);
  }
  console.log("identity properties");
  for (var i = 0; i < allIdentities.length; i++) {
    var currentIdentity = allIdentities.queryElementAt(i, Components.interfaces.nsIMsgIdentity);
    console.log(currentIdentity);
  }

})();
Reference
http://dxr.mozilla.org/comm-release/sou ... anager.idl
http://dxr.mozilla.org/comm-release/sou ... Server.idl
http://dxr.mozilla.org/comm-release/sou ... entity.idl
http://dxr.mozilla.org/comm-release/sou ... Backend.js
Last edited by morat on July 5th, 2019, 11:12 pm, edited 5 times in total.
xdelicacyx
Posts: 111
Joined: April 16th, 2015, 3:15 am

Re: Is there any automation for bulk adding eMail accounts?

Post by xdelicacyx »

Hi Morat, can you show a graphic step by step process please ?
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: Is there any automation for bulk adding eMail accounts?

Post by morat »

@xdelicacyx

Sorry, I don't want to take on your request. I was only testing the create account code.
tanstaafl wrote:The addon doesn't save the username/password for you or add a smtp server.
The above code is the same as the addon except it creates more than one account.
Last edited by morat on June 28th, 2019, 10:24 pm, edited 1 time in total.
xdelicacyx
Posts: 111
Joined: April 16th, 2015, 3:15 am

Re: Is there any automation for bulk adding eMail accounts?

Post by xdelicacyx »

i don't get it, ok
Post Reply