# HG changeset patch # User Sonny Piers # Date 1308117328 -7200 # Node ID c1a19866a23344f42f639083de9e8bac339ec97b # Parent 9dd291d1eebecd2bed4f23d41369d8ebb26f0def Fix some bugs with SMTP settings. diff --git a/configuration.js b/configuration.js --- a/configuration.js +++ b/configuration.js @@ -12,11 +12,11 @@ config.XMPP = { config.SMTP = { host: "smtp.example.com", port: 465, - authentication: "login", - username: "example(@example.com)", - from: "example@example.com", - password: "exemple", - ssl: true + ssl: true, + use_authentication: true, + user: "example(@example)", + pass: "example", + sender: "example@example" }; //Enable easy SMTP configuration for user when register to the component (use http://ispdb.mozillamessaging.com/ database) config.easySMTPConf = true; diff --git a/xmpp2smtp.js b/xmpp2smtp.js --- a/xmpp2smtp.js +++ b/xmpp2smtp.js @@ -63,15 +63,15 @@ cl.on('stanza', else { result.c("x", {type: "form", xmlns: "jabber:x:data"}); var fields; - data ? fields = JSON.parse(data) : fields = {host:"smtp.example.com",authentication: "login", port:"465", ssl: true, username: "example(@example.com)",password: "example", from: "example@example.com"}; + data ? fields = JSON.parse(data) : fields = {host:"smtp.example.com",use_authentication: "login", port:"465", ssl: false, user: "example(@example.com)", pass: "example", sender: "example@example.com"}; result.c("field", {type: "hidden", "var": "FORM_TYPE"}).c("value").t("jabber:iq:register"); result.c("field", {type: "text-single", label: "Host", "var": "host"}).c("required").up().c("value").t(fields.host); result.c("field", {type: "text-single", label: "Port", "var": "port"}).c("required").up().c("value").t(fields.port); result.c("field", {type: "boolean", label: "Enable SSL", "var": "ssl"}).c("required").up().c("value").t(fields.ssl); - result.c("field", {type: "list-single", label: "Authentication method", "var": "authentication"}).c("required").up().c("value").t(fields.authentication).up().c("option", {label: "login"}).c("value").t("login").up().up().c("option", {label: "anonymous"}).c("value").t("anonymous"); - result.c("field", {type: "text-single", label: "Email address", "var": "from"}).c("required").up().c("value").t(fields.from); - result.c("field", {type: "text-single", label: "Username", "var": "username"}).c("required").up().c("value").t(fields.username); - result.c("field", {type: "text-private", label: "Password", "var": "password"}).c("required").up().c("value").t(fields.password); + result.c("field", {type: "boolean", label: "Use authentication", "var": "authentication"}).c("required").up().c("value").t(fields.user_authentication); + result.c("field", {type: "text-single", label: "Email address", "var": "sender"}).c("required").up().c("value").t(fields.from); + result.c("field", {type: "text-single", label: "Username", "var": "user"}).c("required").up().c("value").t(fields.username); + result.c("field", {type: "text-private", label: "Password", "var": "pass"}).c("required").up().c("value").t(fields.password); } cl.send(result); } @@ -94,13 +94,12 @@ cl.on('stanza', test.port = smtp.port; test.host = smtp.hostname; if(smtp.socketType == "SSL") - test.ssl = 1; - else - test.ssl = 0; - test.authentication = "login"; - test.from = username; - test.username = username; - test.password = password; + test.ssl = true; + if((smtp.authentication == "secure") || (smtp.authentication == "plain")) + test.use_authentication = true; + test.sender = username; + test.user = username; + test.pass = password; } fs.writeFile(path, JSON.stringify(test), function () { cl.send(new xmpp.Element("iq", {to: stanza.attrs.from, from: config.XMPP.jid, id: stanza.attrs.id, type: "result"})); @@ -156,16 +155,10 @@ cl.on('stanza', function(err, data) { var settings; data ? settings = JSON.parse(data) : settings = config.SMTP; - smtp.SMTP = { - host: settings.host, - port: settings.port, - use_authentication: true, - user: settings.username, - pass: settings.password - } + smtp.SMTP = settings; smtp.send_mail( { - sender: settings.from, + sender:settings.sender, to: stanza.attrs.to.split("@")[0].replace("%", "@"), subject: (type == "normal" ? stanza.getChildText("subject") : ""), body: stanza.getChildText("body")