diff --git a/lib/server.js b/lib/server.js index 4288c24..fc57c42 100644 --- a/lib/server.js +++ b/lib/server.js @@ -307,6 +307,11 @@ SMTPServerConnection.prototype._onCommand = function(command, payload){ this._onCommandSTARTTLS(); break; + // Get info from proxy server + case "XCLIENT": + this._onCommandXCLIENT(payload.toString("utf-8").trim()); + break; + // No operation case "NOOP": this._onCommandNOOP(); @@ -314,7 +319,7 @@ SMTPServerConnection.prototype._onCommand = function(command, payload){ // Display an error on anything else default: - this.client.send("502 5.5.2 Error: command not recognized"); + // this.client.send("502 5.5.2 Error: command not recognized"); } }; @@ -624,6 +629,21 @@ SMTPServerConnection.prototype._onCommandEHLO = function(host){ }).join("\r\n")); }; +/** + *
No operation. Just returns OK.
+ */ +SMTPServerConnection.prototype._onCommandXCLIENT = function(attributes){ + var attr; + var pairs = attributes.split(" "); + var attributes_dict = {}; + for (var i in pairs) { + attr = pairs[i].split("="); + attributes_dict[attr[0]] = attr[1]; + } + this.envelope.xclient = attributes_dict; + this.client.send("220 success"); +}; + /** *No operation. Just returns OK.
*/ diff --git a/test/server.js b/test/server.js index a3dd2ec..53cea43 100644 --- a/test/server.js +++ b/test/server.js @@ -207,6 +207,47 @@ exports["EHLO setting"] = { } }; +exports["XCLIENT extension"] = { + setUp: function (callback) { + + this.smtp = new simplesmtp.createServer({disableDNSValidation: true}); + this.smtp.listen(PORT_NUMBER, function(err){ + if(err){ + throw err; + }else{ + callback(); + } + }); + + }, + tearDown: function (callback) { + this.smtp.end(callback); + }, + "correct response": function(test) { + runClientMockup(PORT_NUMBER, "localhost", ["EHLO foo", "XCLIENT ADDR=127.0.0.2"], function(resp){ + test.equal("220 success",resp.toString("utf-8").trim()); + test.done(); + }); + }, + "correct parse and save attributes": function(test) { + var messages = [ + "EHLO foo", + "XCLIENT ADDR=127.0.0.1 LOGIN=user@example.org", + "EHLO foo", + "MAIL FROM: