From bcb32968ce8577c5a137f76134d80bc50a2f677e Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Tue, 18 Jan 2022 11:14:16 +1100 Subject: [PATCH] Change emailjs to nodemailer --- EmailJSCache.js => NodeMailerCache.js | 27 ++++++++++++--------------- package.json | 15 +++++++-------- 2 files changed, 19 insertions(+), 23 deletions(-) rename EmailJSCache.js => NodeMailerCache.js (66%) diff --git a/EmailJSCache.js b/NodeMailerCache.js similarity index 66% rename from EmailJSCache.js rename to NodeMailerCache.js index 88f93f9..687db1e 100644 --- a/EmailJSCache.js +++ b/NodeMailerCache.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Nick Downing + * Copyright (C) 2022 Nick Downing * SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -22,26 +22,23 @@ */ 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 diff --git a/package.json b/package.json index 155c9e0..3d5efaf 100644 --- a/package.json +++ b/package.json @@ -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", @@ -15,19 +15,18 @@ "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" + } } -- 2.34.1