Change emailjs to nodemailer master
authorNick Downing <nick@ndcode.org>
Tue, 18 Jan 2022 00:14:16 +0000 (11:14 +1100)
committerNick Downing <nick@ndcode.org>
Tue, 18 Jan 2022 00:14:16 +0000 (11:14 +1100)
NodeMailerCache.js [moved from EmailJSCache.js with 66% similarity]
package.json

similarity index 66%
rename from EmailJSCache.js
rename to NodeMailerCache.js
index 88f93f9..687db1e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Nick Downing <nick@ndcode.org>
+ * Copyright (C) 2022 Nick Downing <nick@ndcode.org>
  * SPDX-License-Identifier: MIT
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  */
 
 let BuildCache = require('@ndcode/build_cache')
-let emailjs = require('emailjs')
-let fs = require('fs')
-let util = require('util')
+let fsPromises = require('fs/promises')
+let nodemailer = require('nodemailer')
 
-let fs_readFile = util.promisify(fs.readFile)
-
-let EmailJSCache = function(diag1, diag) {
-  if (!this instanceof EmailJSCache)
-    throw new Error('EmailJSCache is a constructor')
+let NodeMailerCache = function(diag1, diag) {
+  if (!this instanceof NodeMailerCache)
+    throw new Error('NodeMailerCache is a constructor')
   BuildCache.call(this, diag)
   this.diag1 = diag1
 }
 
-EmailJSCache.prototype = Object.create(BuildCache.prototype)
+NodeMailerCache.prototype = Object.create(BuildCache.prototype)
 
-EmailJSCache.prototype.build = async function(key, result) {
-  let text = await fs_readFile(key, {encoding: 'utf-8'})
-  result.value = emailjs.server.connect(JSON.parse(text))
+NodeMailerCache.prototype.build = async function(key, result) {
+  let text = await fsPromises.readFile(key, {encoding: 'utf-8'})
+  result.value = nodemailer.createTransport(JSON.parse(text))
   if (this.diag1)
-    console.log(`opened emailjs client ${key}`)
+    console.log(`opened nodemailer transport ${key}`)
 }
 
-module.exports = EmailJSCache
+module.exports = NodeMailerCache
index 155c9e0..3d5efaf 100644 (file)
@@ -1,10 +1,10 @@
 {
-  "name": "@ndcode/emailjs_cache",
+  "name": "@ndcode/nodemailer_cache",
   "version": "0.1.0",
-  "description": "Configure emailjs via a JSON file which can be changed while system is live.",
+  "description": "Configure nodemailer via a JSON file which can be changed while system is live.",
   "keywords": [
     "configure",
-    "emailjs",
+    "nodemailer",
     "JSON",
     "persistent",
     "cache",
   "license": "MIT",
   "repository": {
     "type": "git",
-    "url": "https://git.ndcode.org/public/emailjs_cache.git"
+    "url": "https://git.ndcode.org/public/nodemailer_cache.git"
   },
   "bugs": {
     "email": "nick@ndcode.org"
   },
-  "main": "EmailJSCache.js",
+  "main": "NodeMailerCache.js",
   "engines": {
     "node": ">=0.4.0"
   },
   "directories": {},
   "dependencies": {
     "@ndcode/build_cache": "^0.1.0",
-    "emailjs": "^2.2.0"
-  },
-  "devDependencies": {}
+    "nodemailer": "^6.7.2"
+  }
 }