diff --git a/lib/node_mailer.js b/lib/node_mailer.js index e1ccb43..0985ffa 100644 --- a/lib/node_mailer.js +++ b/lib/node_mailer.js @@ -1,5 +1,5 @@ /* Copyright (c) 2009-2010 Marak Squires, Elijah Insua, Fedor Indutny - http://github.com/marak/node_mailer - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without @@ -8,10 +8,10 @@ copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -53,19 +53,21 @@ SMTPClientPool.prototype.send = function send(message, callback) { var hostpool = this.servers[message.SERVER.host] if(!hostpool) hostpool = {}; var client = hostpool[message.SERVER.user] + var pool = this; + var host = message.SERVER.host; if(!client) { client = hostpool[message.SERVER.user] = new SMTPClient(message.SERVER.host,message.SERVER.port,message.SERVER); client.on("close",function() { - if(client == hostClients[options.user]) { + if(client == hostpool[message.SERVER.user]) { //only because this could be crazy long lived and dynamic - delete hostClients[options.user]; - if(Object.keys(hostClients).length == 0) { - delete pool.servers[host] + delete hostpool[message.SERVER.user]; + if(Object.keys(hostpool).length == 0) { + delete pool.servers[host] } } }) client.on("empty",function(){ - delete hostClients[options.user]; + delete hostpool[message.SERVER.user]; client.close();}) } client.sendMail(message,callback);