├── .gitignore ├── config.json ├── examples └── example.js ├── package.json ├── lib ├── dnscheck.js ├── detect.js ├── guess.js └── autoconfig.js ├── README.md └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "disableCache": false, 3 | "redis": { 4 | "host": "localhost", 5 | "port": false, 6 | "db": 4 7 | }, 8 | "cacheExpire": 86400 9 | } -------------------------------------------------------------------------------- /examples/example.js: -------------------------------------------------------------------------------- 1 | var autoconfig = require("../index"); 2 | 3 | var detector = autoconfig.createIMAPSettingsDetector(); 4 | 5 | detector.detect("pipemail@node.ee", "zzzzz", true, function(err, data){ 6 | console.log(err || data); 7 | }); 8 | 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "imap-autoconfig", 3 | "version": "0.1.5", 4 | "description": "Detect IMAP configuration for an e-mail address", 5 | "author" : "Andris Reinman", 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "license": "MIT", 11 | "dependencies": { 12 | "fetch": "*", 13 | "xml2object": "git://github.com/andris9/node-xml2object.git", 14 | "inbox": "*", 15 | "redis": "*" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/dnscheck.js: -------------------------------------------------------------------------------- 1 | var dns = require('dns'); 2 | 3 | // http://tools.ietf.org/html/rfc6186 4 | 5 | module.exports.detectIMAPConnectionSettings = detectIMAPConnectionSettings; 6 | 7 | function detectIMAPConnectionSettings(address, password, callback){ 8 | if(!callback && typeof password == "function"){ 9 | callback = password; 10 | password = undefined; 11 | } 12 | 13 | var parts = (address || "").toString().split("@"), 14 | user = parts.shift() || "", 15 | domain = parts.pop() || ""; 16 | 17 | if(!user || !domain){ 18 | return callback(new Error("Data missing")); 19 | } 20 | 21 | var protos = ["imap", "imaps"], 22 | waitingFor = protos.length, 23 | ready = false; 24 | 25 | for(var i=0, len = protos.length; i