MozillaZine

Is there any automation for bulk adding eMail accounts?

User Help for Mozilla Thunderbird
xdelicacyx
 
Posts: 111
Joined: April 16th, 2015, 3:15 am

Post Posted July 1st, 2019, 8:59 am

I wonder where you can edit or paste anything in the error console..

morat
 
Posts: 3328
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 1st, 2019, 9:15 am

In Thunderbird, the browser console is called the error console.

Tools > Developer Tools > Error Console (Ctrl+Shift+J)

Try typing 1+2 into the command line, then press enter. The error console should evaluate the expression as 3.

Browser Console command line
http://developer.mozilla.org/docs/Tools ... mmand_line

xdelicacyx
 
Posts: 111
Joined: April 16th, 2015, 3:15 am

Post Posted July 4th, 2019, 9:37 am

Hi morat, can you change your code with two other fictive emails including some changes i'd like if any of those can be integrated:

added1@yahoo.com
added2@yahoo.com

1) not imap but pop3
2) including the 2 corresponding passwords (saved)
3) including corresponding pop3 & smtp server names & ports (it doesn't seem to actually create the related smtps..)
4) check new messages every 1 minute.

morat
 
Posts: 3328
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 4th, 2019, 1:22 pm

@xdelicacyx

I don't know how to programmatically save a password.

Here is a guess on how to add smtp servers manually using the error console.

Code: Select all
// add smtp servers manually

(function () {

  var arr = [
    "abracadabra@gmail.com", // google imap account 1
    "hocuspocus@gmail.com",  // google imap account 2
  ];
  for (var i = 0; i < arr.length; i++) {
    var server = MailServices.smtp.createServer();
    server.username = arr[i];
    server.hostname = "smtp.googlemail.com";
    server.description = "Google Mail";
    server.port = 465; // 25 or 465 or 587
    server.socketType = 3; // Components.interfaces.nsMsgSocketType.SSL;
    server.authMethod = 10; // Components.interfaces.nsMsgAuthMethod.OAuth2;
    if (server.authMethod == Components.interfaces.nsMsgAuthMethod.OAuth2) {
      var prefBranch = "mail.smtpserver." + server.key + ".";
      Services.prefs.setCharPref(prefBranch + "oauth2.scope", "https://mail.google.com/");
      Services.prefs.setCharPref(prefBranch + "oauth2.issuer", "accounts.google.com");
    }
    if (!MailServices.smtp.defaultServer ||
        !MailServices.smtp.defaultServer.hostname) {
      MailServices.smtp.defaultServer = server;
    }
  }

})();

Code: Select all
// inspect outgoing server properties

(function () {

  console.log("outgoing server properties");
  var smtpServers = MailServices.smtp.servers;
  while (smtpServers.hasMoreElements()) {
    var existingServer = smtpServers.getNext().
      QueryInterface(Components.interfaces.nsISmtpServer);
    console.log(existingServer);
  }

})();

The code should be considered experimental.

Reference
http://dxr.mozilla.org/comm-release/source/mailnews/compose/public/nsISmtpService.idl
http://dxr.mozilla.org/comm-release/source/mailnews/compose/public/nsISmtpServer.idl
http://dxr.mozilla.org/comm-release/source/mail/components/accountcreation/content/createInBackend.js
Last edited by morat on July 6th, 2019, 5:05 am, edited 2 times in total.

xdelicacyx
 
Posts: 111
Joined: April 16th, 2015, 3:15 am

Post Posted July 4th, 2019, 5:16 pm

Morat, could you please combine both codes so i only have one code to execute per smtp server.

Code: Select all
    // add mail accounts manually

    (function () {

      var arr = [
        ["abracadabra@gmail.com", "Harry Potter"], // google pop3 account 1
        ["hocuspocus@gmail.com", "Ron Weasley"],   // google pop3 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 = "pop.googlemail.com"; // imap.googlemail.com or pop.googlemail.com
        var type = "pop3"; // 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;
        server.biffMinutes = 1; // Check for new messages every 1 minutes
        server.prettyName = username;
        server.doBiff = false;
        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
     // add smtp servers manually

    (function () {

      var arr = [
        "abracadabra@gmail.com", // google smtp account 1
        "hocuspocus@gmail.com",  // google smtp account 2
      ];
      for (var i = 0; i < arr.length; i++) {
        var server = MailServices.smtp.createServer();
        server.username = arr[i];
        server.hostname = "smtp.googlemail.com";
        server.description = "Google Mail";
        server.port = 465; // 25 or 465
        server.socketType = 3; // Components.interfaces.nsMsgSocketType.SSL;
        server.authMethod = 10; // Components.interfaces.nsMsgAuthMethod.OAuth2;
        if (server.authMethod == Components.interfaces.nsMsgAuthMethod.OAuth2) {
          var prefBranch = "mail.smtpserver." + server.key + ".";
          Services.prefs.setCharPref(prefBranch + "oauth2.scope", "https://mail.google.com/");
          Services.prefs.setCharPref(prefBranch + "oauth2.issuer", "accounts.google.com");
        }
        if (!MailServices.smtp.defaultServer ||
            !MailServices.smtp.defaultServer.hostname) {
          MailServices.smtp.defaultServer = server;
        }
      }

    })();
Last edited by xdelicacyx on July 5th, 2019, 10:00 am, edited 4 times in total.

xdelicacyx
 
Posts: 111
Joined: April 16th, 2015, 3:15 am

Post Posted July 4th, 2019, 6:19 pm

& finally, see if you could add those missing ones:

check for new messages at startup (box checked)
check for new messages every (x) minutes (box checked)
automatically download new messages (box checked)
In "composition tab" start my reply (above)

& the sadly unfixed password saving ((

I've been looking there unsuccessfully with various tests, maybe this could help:
https://hg.mozilla.org/comm-central/rev/895928822eb3

morat
 
Posts: 3328
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 5th, 2019, 11:17 pm

@xdelicacyx

Give me a week or so. I have to create a yahoo account to test the code.

I got it working somewhat. I can save the password for google imap accounts using authentication method normal password, but not OAuth2. I think google forces you save the password using the webpage.

P.S.

Stupid google. I got a "Critical security alert" message from google after testing the code. I can't login to one of my throw away accounts now.

xdelicacyx
 
Posts: 111
Joined: April 16th, 2015, 3:15 am

Post Posted July 6th, 2019, 4:12 am

Ok morat, that's good news, password saving will make the code finally useful ))

It's true that an imap account is always a better solution to review & control emails stupidly trapped in the spam field because of incorrect imposed spam filters by gmail,
but not all email servers offer imap. nevertheless, that's not a problem, as you gave me the way to change imap to pop3 in the code.

& yes, google forces webpage logins for pop3 or imap. The good news is that gmail is not alone in the emailing world & i won't be using their accounts in the future, for emailing.
i even have worse by google, because i use 4 gmail accounts in wlm, at the 15th or 20th link i get in google searches, i win a captcha, & those google captchas appear EVERYWHERE
in other pages for multiple reasons, & naturally, i can't use "buster" addon on firefox v42, the only latest version of firefox that accepts all my addons ... because that addon works
on a minimum of ff v54 or so .. . those captchas are actually ruinning my websurfing. for google everyone is a shitty bot.. i call that military authoritarianism ... google are the biggest
shitheads in the web, imposing u more & more control over your own internet consumption time by trying to validate shit images frame after frame ...

Keep me updated for the code, thanks a lot.

morat
 
Posts: 3328
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 6th, 2019, 4:53 am

You need a mobile phone number to create a yahoo account. It is too much trouble to test the code.

Here is the code that I got working somewhat.

Code: Select all
// adds incoming and outgoing servers, add local folders server

/* reference

   http://dxr.mozilla.org/comm-release/source/mailnews/base/public/nsIMsgAccountManager.idl
   http://dxr.mozilla.org/comm-release/source/mailnews/base/public/nsIMsgIncomingServer.idl
   http://dxr.mozilla.org/comm-release/source/mailnews/base/public/nsIMsgIdentity.idl
   http://dxr.mozilla.org/comm-release/source/mailnews/compose/public/nsISmtpService.idl
   http://dxr.mozilla.org/comm-release/source/mailnews/compose/public/nsISmtpServer.idl
   http://dxr.mozilla.org/comm-release/source/mail/components/accountcreation/content/createInBackend.js

*/

(function () {

  var arr = [
    ["abracadabra@gmail.com", "hippogriff123", "Harry Potter"], // Google IMAP Account 1
    ["hocuspocus@gmail.com",  "phoenix123",    "Ron Weasley"],  // Google IMAP Account 2
  ];

  function rememberPassword(aServer, aPassword) {
    // Google IMAP Account succeeds with Authentication method: Normal password
    // Google IMAP Account    fails with Authentication method: OAuth2
    // use google.com webpage to save password with OAuth2
    if (aServer instanceof Components.interfaces.nsIMsgIncomingServer) {
      var passwordURI = aServer.localStoreType + "://" + aServer.hostName;
    } else if (aServer instanceof Components.interfaces.nsISmtpServer) {
      var passwordURI = "smtp://" + aServer.hostName;
    }
    var login = Components.classes["@mozilla.org/login-manager/loginInfo;1"].
      createInstance(Components.interfaces.nsILoginInfo);
    login.init(passwordURI, null, passwordURI, aServer.username, aPassword, "", "");
    try {
      Services.logins.addLogin(login);
    } catch (e) {
      console.log(e);
    }
  }
  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 password = arr[i][1];
       var hostname = "imap.googlemail.com"; // imap.googlemail.com or pop.googlemail.com
    // var hostname = "pop.mail.yahoo.com";  // imap.mail.yahoo.com or pop.mail.yahoo.com
       var type = "imap";
    // var type = "pop3";
    var inServer = accountManager.createIncomingServer(username, hostname, type);
    inServer.port = 993; // 993 for imap or 995 for pop3

    // inServer.authMethod =  1; // Components.interfaces.nsMsgAuthMethod.none;
    // inServer.authMethod =  2; // Components.interfaces.nsMsgAuthMethod.old;
       inServer.authMethod =  3; // Components.interfaces.nsMsgAuthMethod.passwordCleartext; // Normal password
    // inServer.authMethod =  4; // Components.interfaces.nsMsgAuthMethod.passwordEncrypted; // Encrypted password
    // inServer.authMethod =  5; // Components.interfaces.nsMsgAuthMethod.GSSAPI;            // Kerberos / GSSAPI
    // inServer.authMethod =  6; // Components.interfaces.nsMsgAuthMethod.NTLM;              // NTLM
    // inServer.authMethod =  7; // Components.interfaces.nsMsgAuthMethod.External;          // TLS Certificate
    // inServer.authMethod =  8; // Components.interfaces.nsMsgAuthMethod.secure;
    // inServer.authMethod =  9; // Components.interfaces.nsMsgAuthMethod.anything;
    // inServer.authMethod = 10; // Components.interfaces.nsMsgAuthMethod.OAuth2;            // OAuth2

    if (inServer.authMethod == Components.interfaces.nsMsgAuthMethod.OAuth2) {
      inServer.setCharValue("oauth2.scope", "https://mail.google.com/");
      inServer.setCharValue("oauth2.issuer", "accounts.google.com");
    }
    inServer.password = password;
    rememberPassword(inServer, password);

    // inServer.socketType = 0; // Components.interfaces.nsMsgSocketType.plain;          // None
    // inServer.socketType = 1; // Components.interfaces.nsMsgSocketType.trySTARTTLS;
    // inServer.socketType = 2; // Components.interfaces.nsMsgSocketType.alwaysSTARTTLS; // STARTTLS
       inServer.socketType = 3; // Components.interfaces.nsMsgSocketType.SSL;            // SSL/TLS

    inServer.prettyName = username;
    inServer.loginAtStartUp = true; // [check] Check for new messages at startup
    inServer.doBiff = true;         // [check] Check for new messages every    minutes
    inServer.biffMinutes = 15;      //         Check for new messages every 15 minutes
 // inServer.downloadOnBiff = true; // [check] Automatically download new messages, pop3 only
    inServer.valid = true;
    var identity = accountManager.createIdentity();
    identity.fullName = arr[i][2];
    identity.email = username;
    identity.autoQuote = true; // [check] Automatically quote the original message when replying
    identity.replyOnTop = 1;   // 0: start my reply below quote, 1: start my reply above quote, 2: select quote
    identity.valid = true;
    var account = accountManager.createAccount();
    account.addIdentity(identity);
    account.incomingServer = inServer;
    if (!accountManager.defaultAccount) {
      accountManager.defaultAccount = account;
    }
  }
  for (var i = 0; i < arr.length; i++) {
    var username = arr[i][0];
    var password = arr[i][1];
    var outServer = MailServices.smtp.createServer();
    outServer.username = username;
    outServer.hostname = "smtp.googlemail.com"; // smtp.googlemail.com or smtp.mail.yahoo.com
    outServer.description = "Google Mail";
    outServer.port = 465; // 25 or 465 or 587

    // outServer.authMethod =  1; // Components.interfaces.nsMsgAuthMethod.none;
    // outServer.authMethod =  2; // Components.interfaces.nsMsgAuthMethod.old;
       outServer.authMethod =  3; // Components.interfaces.nsMsgAuthMethod.passwordCleartext; // Normal password
    // outServer.authMethod =  4; // Components.interfaces.nsMsgAuthMethod.passwordEncrypted; // Encrypted password
    // outServer.authMethod =  5; // Components.interfaces.nsMsgAuthMethod.GSSAPI;            // Kerberos / GSSAPI
    // outServer.authMethod =  6; // Components.interfaces.nsMsgAuthMethod.NTLM;              // NTLM
    // outServer.authMethod =  7; // Components.interfaces.nsMsgAuthMethod.External;          // TLS Certificate
    // outServer.authMethod =  8; // Components.interfaces.nsMsgAuthMethod.secure;
    // outServer.authMethod =  9; // Components.interfaces.nsMsgAuthMethod.anything;
    // outServer.authMethod = 10; // Components.interfaces.nsMsgAuthMethod.OAuth2;            // OAuth2

    if (outServer.authMethod == Components.interfaces.nsMsgAuthMethod.OAuth2) {
      var prefBranch = "mail.smtpserver." + outServer.key + ".";
      Services.prefs.setCharPref(prefBranch + "oauth2.scope", "https://mail.google.com/");
      Services.prefs.setCharPref(prefBranch + "oauth2.issuer", "accounts.google.com");
    }
    outServer.password = password;
    rememberPassword(outServer, password);

    // outServer.socketType = 0; // Components.interfaces.nsMsgSocketType.plain;          // None
    // outServer.socketType = 1; // Components.interfaces.nsMsgSocketType.trySTARTTLS;
    // outServer.socketType = 2; // Components.interfaces.nsMsgSocketType.alwaysSTARTTLS; // STARTTLS
       outServer.socketType = 3; // Components.interfaces.nsMsgSocketType.SSL;            // SSL/TLS

    if (!MailServices.smtp.defaultServer ||
        !MailServices.smtp.defaultServer.hostname) {
      MailServices.smtp.defaultServer = outServer;
    }
  }
  var localFoldersExists;
  try {
    localFoldersExists = MailServices.accounts.localFoldersServer;
  } catch (e) {
    localFoldersExists = false;
  }
  if (!localFoldersExists) {
    MailServices.accounts.createLocalMailAccount();
  }

})();

The code should be considered experimental.

Reference
http://dxr.mozilla.org/comm-release/source/mailnews/base/public/nsIMsgAccountManager.idl
http://dxr.mozilla.org/comm-release/source/mailnews/base/public/nsIMsgIncomingServer.idl
http://dxr.mozilla.org/comm-release/source/mailnews/base/public/nsIMsgIdentity.idl
http://dxr.mozilla.org/comm-release/source/mailnews/compose/public/nsISmtpService.idl
http://dxr.mozilla.org/comm-release/source/mailnews/compose/public/nsISmtpServer.idl
http://dxr.mozilla.org/comm-release/source/mail/components/accountcreation/content/createInBackend.js

xdelicacyx
 
Posts: 111
Joined: April 16th, 2015, 3:15 am

Post Posted July 6th, 2019, 7:09 am

Thank you so, i realized you included all specifications for accounts ))

I forgot two final minor issues, it'd be great to integrate those two:

On server settings tab:
Leave messages on server (disabled)

On junk settings tab:
Enable adaptive junk mail controls (disabled)



& also, would there be a minimal code for bulk removal in imap/pop3 & in smtp, providing email names ?

morat
 
Posts: 3328
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 6th, 2019, 9:48 am

You don't need to add properties with default values to the code.

Isn't leave messages on server (unchecked) the default for pop3 accounts?

i.e. pref("mail.server.default.leave_on_server", false);

Code: Select all
inServer.leaveMessagesOnServer = true; // [check] Leave messages on server, pop3 only

I don't know how to set the junk mail controls. The following line fails to change the spam setting.

Code: Select all
inServer.spamSettings.level = 0; // [uncheck] Enable adaptive junk mail controls for this account

Reference
http://dxr.mozilla.org/comm-release/source/mailnews/base/public/nsISpamSettings.idl

xdelicacyx
 
Posts: 111
Joined: April 16th, 2015, 3:15 am

Post Posted July 6th, 2019, 10:31 am

Ok, i'll try to tweak the code with your given infos. & what about a minimal code for bulk removal in imap/pop3 & in smtp, providing email names ?

xdelicacyx
 
Posts: 111
Joined: April 16th, 2015, 3:15 am

Post Posted July 6th, 2019, 10:44 am

I tried to add both commands & i get this:
[Exception... "Cannot modify properties of a WrappedNative" nsresult: "0x80570034 (NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN)" location: "JS frame :: debugger eval code :: <TOP_LEVEL> :: line 80" data: no]
It seems that i cannot keep
// inServer.downloadOnBiff = true; // [check] Automatically download new messages, pop3 only
in the code if i don't change everything to pop3..
if that's true, it means i have to save 2 different codes, one for pop3, & one for imap.
& the junk filter command doesn't seem to work either with 0 or 1...


Code: Select all
    // adds incoming and outgoing servers, add local folders server

    /* reference

       http://dxr.mozilla.org/comm-release/source/mailnews/base/public/nsIMsgAccountManager.idl
       http://dxr.mozilla.org/comm-release/source/mailnews/base/public/nsIMsgIncomingServer.idl
       http://dxr.mozilla.org/comm-release/source/mailnews/base/public/nsIMsgIdentity.idl
       http://dxr.mozilla.org/comm-release/source/mailnews/compose/public/nsISmtpService.idl
       http://dxr.mozilla.org/comm-release/source/mailnews/compose/public/nsISmtpServer.idl
       http://dxr.mozilla.org/comm-release/source/mail/components/accountcreation/content/createInBackend.js

    */

    (function () {

      var arr = [
        ["abracadabra@gmail.com", "hippogriff123", "Harry Potter"], // Google IMAP Account 1
        ["hocuspocus@gmail.com",  "phoenix123",    "Ron Weasley"],  // Google IMAP Account 2
      ];

      function rememberPassword(aServer, aPassword) {
        // Google IMAP Account succeeds with Authentication method: Normal password
        // Google IMAP Account    fails with Authentication method: OAuth2
        // use google.com webpage to save password with OAuth2
        if (aServer instanceof Components.interfaces.nsIMsgIncomingServer) {
          var passwordURI = aServer.localStoreType + "://" + aServer.hostName;
        } else if (aServer instanceof Components.interfaces.nsISmtpServer) {
          var passwordURI = "smtp://" + aServer.hostName;
        }
        var login = Components.classes["@mozilla.org/login-manager/loginInfo;1"].
          createInstance(Components.interfaces.nsILoginInfo);
        login.init(passwordURI, null, passwordURI, aServer.username, aPassword, "", "");
        try {
          Services.logins.addLogin(login);
        } catch (e) {
          console.log(e);
        }
      }
      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 password = arr[i][1];
           var hostname = "imap.googlemail.com"; // imap.googlemail.com or pop.googlemail.com
        // var hostname = "pop.mail.yahoo.com";  // imap.mail.yahoo.com or pop.mail.yahoo.com
           var type = "imap";
        // var type = "pop3";
        var inServer = accountManager.createIncomingServer(username, hostname, type);
        inServer.port = 993; // 993 for imap or 995 for pop3

        // inServer.authMethod =  1; // Components.interfaces.nsMsgAuthMethod.none;
        // inServer.authMethod =  2; // Components.interfaces.nsMsgAuthMethod.old;
           inServer.authMethod =  3; // Components.interfaces.nsMsgAuthMethod.passwordCleartext; // Normal password
        // inServer.authMethod =  4; // Components.interfaces.nsMsgAuthMethod.passwordEncrypted; // Encrypted password
        // inServer.authMethod =  5; // Components.interfaces.nsMsgAuthMethod.GSSAPI;            // Kerberos / GSSAPI
        // inServer.authMethod =  6; // Components.interfaces.nsMsgAuthMethod.NTLM;              // NTLM
        // inServer.authMethod =  7; // Components.interfaces.nsMsgAuthMethod.External;          // TLS Certificate
        // inServer.authMethod =  8; // Components.interfaces.nsMsgAuthMethod.secure;
        // inServer.authMethod =  9; // Components.interfaces.nsMsgAuthMethod.anything;
        // inServer.authMethod = 10; // Components.interfaces.nsMsgAuthMethod.OAuth2;            // OAuth2

        if (inServer.authMethod == Components.interfaces.nsMsgAuthMethod.OAuth2) {
          inServer.setCharValue("oauth2.scope", "https://mail.google.com/");
          inServer.setCharValue("oauth2.issuer", "accounts.google.com");
        }
        inServer.password = password;
        rememberPassword(inServer, password);

        // inServer.socketType = 0; // Components.interfaces.nsMsgSocketType.plain;          // None
        // inServer.socketType = 1; // Components.interfaces.nsMsgSocketType.trySTARTTLS;
        // inServer.socketType = 2; // Components.interfaces.nsMsgSocketType.alwaysSTARTTLS; // STARTTLS
           inServer.socketType = 3; // Components.interfaces.nsMsgSocketType.SSL;            // SSL/TLS

        inServer.prettyName = username;
        inServer.loginAtStartUp = true; // [check] Check for new messages at startup
        inServer.doBiff = true;         // [check] Check for new messages every    minutes
        inServer.biffMinutes = 1;      //         Check for new messages every 1 minutes
     // inServer.downloadOnBiff = true; // [check] Automatically download new messages, pop3 only
        inServer.valid = true;
        inServer.leaveMessagesOnServer = false; // [check] Leave messages on server, pop3 only
        inServer.spamSettings.level = 0; // [uncheck] Enable adaptive junk mail controls for this account
        var identity = accountManager.createIdentity();
        identity.fullName = arr[i][2];
        identity.email = username;
        identity.autoQuote = true; // [check] Automatically quote the original message when replying
        identity.replyOnTop = 1;   // 0: start my reply below quote, 1: start my reply above quote, 2: select quote
        identity.valid = true;
        var account = accountManager.createAccount();
        account.addIdentity(identity);
        account.incomingServer = inServer;
        if (!accountManager.defaultAccount) {
          accountManager.defaultAccount = account;
        }
      }
      for (var i = 0; i < arr.length; i++) {
        var username = arr[i][0];
        var password = arr[i][1];
        var outServer = MailServices.smtp.createServer();
        outServer.username = username;
        outServer.hostname = "smtp.googlemail.com"; // smtp.googlemail.com or smtp.mail.yahoo.com
        outServer.description = "Google Mail";
        outServer.port = 465; // 25 or 465 or 587

        // outServer.authMethod =  1; // Components.interfaces.nsMsgAuthMethod.none;
        // outServer.authMethod =  2; // Components.interfaces.nsMsgAuthMethod.old;
           outServer.authMethod =  3; // Components.interfaces.nsMsgAuthMethod.passwordCleartext; // Normal password
        // outServer.authMethod =  4; // Components.interfaces.nsMsgAuthMethod.passwordEncrypted; // Encrypted password
        // outServer.authMethod =  5; // Components.interfaces.nsMsgAuthMethod.GSSAPI;            // Kerberos / GSSAPI
        // outServer.authMethod =  6; // Components.interfaces.nsMsgAuthMethod.NTLM;              // NTLM
        // outServer.authMethod =  7; // Components.interfaces.nsMsgAuthMethod.External;          // TLS Certificate
        // outServer.authMethod =  8; // Components.interfaces.nsMsgAuthMethod.secure;
        // outServer.authMethod =  9; // Components.interfaces.nsMsgAuthMethod.anything;
        // outServer.authMethod = 10; // Components.interfaces.nsMsgAuthMethod.OAuth2;            // OAuth2

        if (outServer.authMethod == Components.interfaces.nsMsgAuthMethod.OAuth2) {
          var prefBranch = "mail.smtpserver." + outServer.key + ".";
          Services.prefs.setCharPref(prefBranch + "oauth2.scope", "https://mail.google.com/");
          Services.prefs.setCharPref(prefBranch + "oauth2.issuer", "accounts.google.com");
        }
        outServer.password = password;
        rememberPassword(outServer, password);

        // outServer.socketType = 0; // Components.interfaces.nsMsgSocketType.plain;          // None
        // outServer.socketType = 1; // Components.interfaces.nsMsgSocketType.trySTARTTLS;
        // outServer.socketType = 2; // Components.interfaces.nsMsgSocketType.alwaysSTARTTLS; // STARTTLS
           outServer.socketType = 3; // Components.interfaces.nsMsgSocketType.SSL;            // SSL/TLS

        if (!MailServices.smtp.defaultServer ||
            !MailServices.smtp.defaultServer.hostname) {
          MailServices.smtp.defaultServer = outServer;
        }
      }
      var localFoldersExists;
      try {
        localFoldersExists = MailServices.accounts.localFoldersServer;
      } catch (e) {
        localFoldersExists = false;
      }
      if (!localFoldersExists) {
        MailServices.accounts.createLocalMailAccount();
      }

    })();

morat
 
Posts: 3328
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 6th, 2019, 11:20 am

The code I posted works for google imap accounts with authentication method normal password.

You need to hire a developer to fix the code for yahoo accounts. I can't fix the code without creating a yahoo account. (too much trouble)

xdelicacyx
 
Posts: 111
Joined: April 16th, 2015, 3:15 am

Post Posted July 6th, 2019, 11:29 am

& what about a minimal code for bulk removal in imap/pop3 & in smtp, providing email names ?

Return to Thunderbird Support


Who is online

Users browsing this forum: No registered users and 8 guests