/*
- * 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
{
- "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"
+ }
}