How to use the nodemailer.SMTPClient function in nodemailer

To help you get started, we’ve selected a few nodemailer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Marak / node_mailer / lib / node_mailer.js View on Github external
SMTPClientPool.prototype.addClient = function(port,host,options) {
  if(this.servers[host] && this.servers[host][options.user]) return;
  var hostClients = this.servers[host] || (this.servers[host] = {});
  var pool = this;
  var client = hostClients[options.user] = new SMTPClient(host,port,options);
  client.on("close",function() {
    if(client == hostClients[options.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]
      }
    }
  })
  client.on("empty",function(){
	delete hostClients[options.user];
	client.close();})
}
SMTPClientPool.prototype.send = function send(message, callback) {
github Marak / node_mailer / lib / node_mailer.js View on Github external
SMTPClientPool.prototype.send = function send(message, callback) {
  var hostpool = this.servers[message.SERVER.host]
  if(!hostpool) hostpool = {};
  var client = hostpool[message.SERVER.user]
  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]) {
          //only because this could be crazy long lived and dynamic
          delete hostClients[options.user];
          if(Object.keys(hostClients).length == 0) {
       delete pool.servers[host]
          }
        }
    })
    client.on("empty",function(){
     delete hostClients[options.user];
     client.close();})
  }
  client.sendMail(message,callback);
  client.on('error', callback);
}